I am using UIDocumentInteractionController to open the list of available pdf application in my device when i click on button but now i want to display setting table which will show the list of all the application and user will be directlly redirect to that applcation next time without displaying the actionsheet or any option
my cade is as below:
docController = [UIDocumentInteractionController interactionControllerWithURL:url];
docController.delegate = self;
[docController retain];
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
how can i do that?
You don't, it's not possible using the official SDK to:
Get a list of apps that open a certain file
Open a file with a certain app
One thing you can do is open a URL and the system will decide which app to open.
Related
I am accessing the photo gallery using below code :
UIImagePickerController* picker = [UIImagePickerController new];
picker.sourceType = type;
picker.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:type];
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
So I user open Gallery for first time then application is display popup like this :
If user select the OK then its work fine. But if user select the Don't Allow then photo gallery is not able to access from application. My question is if user open Photo Gallery then how to check whether photo gallery is accessible or not.
If user is not allow then application is display the screen like this :
But is there any way to check Accessibility before opening the window.
Thanks,
You can check your access ability using ALAuthorizationStatusAuthorized.
Check authorization status of the app.
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
//THen code here ,,,,
}
you might looking for this solution in failure block you can show alert to user that then can give access by go to settings....
I'm displaying a PDF in my app and I want to have to same "openIn" functionality as the default iOS mail client.
The code I have is as follows:
NSURL *url = [NSURL fileURLWithPath:#"/var/mobile/Applications/21D850EA-409A-4231-BDFE-6B79FC721DA3/Library/Caches/1373665423163257247920130712/84cd7f88cf1b400cb1f4a4d6ac439649.pdf"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[url] applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
I've hard coded the path for testing.
The first image below is how it looks in the mail client.
The second image is how it looks in my app.
Any help would be great.
You misunderstand what is happening. In the Mail app you have opened the PDF in the preview window. The actions icon then brings up a UIDocumentInteractionController with the standard "options" menu.
The UIActivityController does not provide any "open in" functionality. If your want the same options in your app as from the Mail attachment preview window, use a UIDocumentInteractionController and use one of the presentOptionsMenu... methods.
I have an app that shares with instagram built for iOS5 and now in iOS6, sharing no longer works although canOpenURL returns true and code executes. The images are saved to the documents folder of the application with a .igo extension. This is passed to instagram with com.instagram.exclusivegram.
The code is below, it enters the if statement and displays "here in" but does not open the Share With dialog like it used to at the bottom of the screen.
NSLog(#"%#", _imgToUpload);
NSURL *instagramURL = [NSURL URLWithString:#"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
uidController = [[UIDocumentInteractionController alloc] init];
//imageToUpload is a file path with .igo file extension
uidController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:_imgToUpload]];
uidController.UTI = #"com.instagram.exclusivegram";
uidController.delegate = self;
CGRect navRect = self.view.frame;
[uidController presentOpenInMenuFromRect:navRect inView:[UIApplication sharedApplication].keyWindow animated:YES];
NSLog(#"here in");
}
_imgToUpload is providing the correct filepath as well.
Thank you,
Nick
Just did some testing and found a solution. Do not present in the keyWindow.
[uidController presentOpenInMenuFromRect:navRect inView:self.view animated:YES];
I have tested this and it will fix the problem.
Another reason for the uidocumentinteraction controller not working in iOS6 is that the new action sheet/launch panel (it shows apps available to open the doc) is now used. My app which worked fine launching iBooks with iOS5 failed because I launched from viewDidLoad which was now too early and I got an error on the current view controller 'whose view is not in the window hierarchy' so I changed my code to performselector after delay of 1 second. The app now calls iBooks via the new panel.
I want to show the power point presentation in iphone .
Is this possible ? because I want to show it in the slide show manner .
I however able to show ppt in the webView . but it is in the vertical manner .
I think if i convert all ppt into images and then show that images into scrollbar but i don't know if this is possible .
so if anyone have idea about this . please share here
Edit..
I am using UIDocumentInteractionController but I am unable to see the ppt .. this is the code ..
NSString * path = [[NSBundle mainBundle] pathForResource:#"Sun2" ofType:#"ppt"];
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
docController.delegate = self;
[docController retain];
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
You could write some functions that do exactly as you have described, or consider the use of Apple's own UIDocumentInteractionController.
Be sure to implement the delegate method:
(UIViewController*)documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController*)controller
... which will return the view controller that is to push the document controller.
You may also find some of the code in an old question of mine to be helpful:
UIDocumentInteractionController crashing upon exit
My app needs to open some file types in other apps, like dropbox app does, it could list the installed apps which could open specific types of file.
How can get the app list?
You'll want to use UIDocumentInteractionController. See also the Document Interaction Programming Guide.
You can use QLPreviewController from the official docs.
Expanding on jtbandes's answer, here's the code that worked for me:
NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *popup = [UIDocumentInteractionController interactionControllerWithURL:url];
[popup setDelegate:self];
[popup presentPreviewAnimated:YES];
And don't forget to include this in your H file:
#interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>
Also worth noting: this will open a new fullscreen view that has a Document Viewer, as well as the Share button that offers all the various apps that can open this file. If you're just looking for the Share popup, equivalent to the UIActivityViewController, this will do it, but with some extra functionality you may not want.