-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I load internet files? #14
Comments
The problem is: UIDocumentInteractionController relies on local files. You coukd try to create temporary files, by donwloading the files you want to export from the internet. Than open the TTOpenInAppActivity, afterwards you can delete the temporary files. |
Thanks @honkmaster ;) |
Another notice: You don`t have to use nsdata as activity item. You just have to use a NSURL-Object pointing to a local file. |
Thanks @honkmaster I discover later ;), I've to implement then a cache system downloading locally files cleaning them with care :) |
Maybe you can help me @honkmaster , I'm trying to do the way you comment but the app crash and I don't know why because I don't get any error in console. That's the code: //Generating activities
TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andRect:self.view.frame];
[activities addObject:openInAppActivity];
TUSafariActivity *safari = [[TUSafariActivity alloc] init];
[activities addObject:safari];
ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init];
[activities addObject:chromeActivity];
// Generating and presentin UIActivity
if([NSData dataWithContentsOfFile:upload.path]){
//We've the data locally
UIActivityViewController *activityViewController= [[UIActivityViewController alloc] initWithActivityItems:@[[NSURL URLWithString:upload.path]] applicationActivities:activities];
//openInAppActivity.superViewController = activityViewController;
[self.navigationController presentViewController:activityViewController animated:YES completion:NULL];
}else{
//We've to download
[SVProgressHUD show];
[upload downloadData:^(float progress) {
if(progress==1.0){
[SVProgressHUD dismiss];
UIActivityViewController *activityViewController= [[UIActivityViewController alloc] initWithActivityItems:@[[NSURL URLWithString:upload.path]] applicationActivities:activities];
//openInAppActivity.superViewController = activityViewController;
[self.navigationController presentViewController:activityViewController animated:YES completion:NULL];
}
} withErrorBlock:^(NSError *error) {
[SVProgressHUD showErrorWithStatus:NSLocalizedString(@"Error loading attachment", nil)];
}];
} And from console I don't receive any kind of error. It's strange |
Maybe you have to use fileURLwithPath (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/clm/NSURL/fileURLWithPath:) .... |
Sure @honkmaster , I discovered 😛 thanks for all! |
I've implemented in my application a gallery with remote resources, and the one that I can't represent like images, gifs, videos.. I would like to open them with TTOpenInAppActivity. The problem is that I don't have the resources downloaded, I have their URLs. If I add the items to TTOpenInAppActivity in url format and for example the resource is a PDF I can't open it with external apps like Dropbox/Books...
I've tried to download it before and passing NSData to TTOpenInAppActivity, but I still have the same problem. Any suggestion about how can I get it?
Thanks
The text was updated successfully, but these errors were encountered: