UIDocumentInteractionController no longer works in iOS6 - iphone

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.

Related

UIActivityView doesn't display other apps as option to open pdf

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.

How to control unwanted Pop-up that appear when making call within app

I am developing an app about making call and returning to app when calling ended. Here is my code;
**callWebview = [[UIWebView alloc] init];
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telUrl]];**
This is ok but when url request is being sent, A pop up appears on the screen.
This is the screenshot when I press the button and run the code at upside;
So , Here is my question;
Can I block this pop up to appear on the screen ?
If I can't how can I change the message body and buttons of this popup ?
Thanks...
If you do not use the UIWebView the message will not appear, but then you will not be able to come beck to the app.
To make a call with out the alert:
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
// Check if the iOS device support dialing a number
if ( [[UIApplication sharedApplication] canOpenURL:telUrl]) {
[[UIApplication sharedApplication] openURL:telUrl];
}
But there is no solution that will do exactly what you desire, so either it is the dialog or no dialog but not retuning to you app.
Try the following instead:
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
[[UIApplication sharedApplication] openURL:telUrl];

iOS 6.1 UIWebview crashes when clicked on play youtube video inside a webpage

I am trying to show a website inside app. The website which i am trying to load has got a youtube video in it. The website loads properly in UIWebView and also lists the youtube video. But when I click on youtube video, the app crashes.
Crash log just says:
setting movie path: http://r19---sn-aig7knl7.c.youtube.com/videoplayback?...............
The website when loaded in Safari works fine, it even plays youtube video full screen.
Please help me in fixing this issue.
11 Feb 2013 - UPDATE
The issue is observed only on iOS Simulator 6.1. On Device everything works fine.
Detailed Info:
I have a custom UIViewController(TestWebViewController) which has an instance of UIWebView and implements UIWebViewDelegate. I have added a UIViewController in Storyboard and added UIWebView inside it, linked this UIViewController to my custom TestWebViewController and linked IBOutlet and delegate for UIWebView.
On Clicking a button, I am programmatically instantiating TestWebViewController using
TestWebViewController *testWebVC = [self.storyboard instantiateViewControllerWithIdentifier:#"testWebVC"];
testWebVC.view.frame = self.view.frame;
[testWebVC loadWebViewWithUrl:TEST_URL];
[self presentViewController:testWebVC animated:YES completion:nil];
As scott said in his comment, I removed my breakpoint for all exceptions and my error went away.
Hope this will help to others.
Modal view on iOS 5.0 and iOS 5.1 is the problem that causes crash on full screen video, AFAIK. They just changed hierarchy of views in that version of iOS (parentViewController and presentingViewController) and that is the aftermath. I asked about it long time ago here and one more same question is here and still no one knows what to do.
First of all, they fixed it in 6.0, I guess, that's good.
For 5.1 we changed design a little and avoided modal view. Do it, if it is possible in your situation.
TestWebViewController *testWebVC = [self.storyboard instantiateViewControllerWithIdentifier:#"testWebVC"];
[testWebVC LoadWebView:#"YOUR URL STRING"];
[self presentViewController:testWebVC animated:YES completion:nil];
AND in TestWebViewController class
-(void)LoadWebView:(NSString *)address {
addressStr = address;
}
- (void)viewDidLoad
{
[super viewDidLoad];
url = [NSURL URLWithString:addressStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url] ;
[myWebView loadRequest:request] ;
}

How to open settings from our app in ios5.1? [duplicate]

Looks like iOS 5.1 has broken the standard URL encoding for navigating a user to a Preference.
For example:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=TWITTER"]];
Works in iOS 5.0 but not in iOS 5.1 (both device and simulator).
Has anyone found a way to replicate this functionality in iOS 5.1?
It is little tricky , i get by the removing the subviews in *TWTWeetComposeViewController*, so it shows only alert when user is not loged in and by the clicking on setting button , we can open Setting page in my app.
+ (void)setAlertForSettingPage :(id)delegate
{
// Set up the built-in twitter composition view controller.
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
[delegate dismissModalViewControllerAnimated:YES];
}];
// Present the tweet composition view controller modally.
[delegate presentModalViewController:tweetViewController animated:YES];
//tweetViewController.view.hidden = YES;
for (UIView *view in tweetViewController.view.subviews){
[view removeFromSuperview];
}
}
here , delegate is your viewcontroller , if you are using this method inside your viewcontroller just use self instead of delegate.
EDIT: If you get any deprecated errors, use the following iOS6 compatible code instead:
- (void)setAlertForSettingPage
{
// Set up the built-in twitter composition view controller.
SLComposeViewController *tweetViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
// Present the tweet composition view controller modally.
[self presentViewController:tweetViewController animated:YES completion:nil];
for (UIView *view in tweetViewController.view.subviews){
[view removeFromSuperview];
}
}
No I don’t know a way to replicate this functionality.
But what you can do is file a Radar requesting the restoration. Here is a radar requesting that the schemes be documented in the first place.
David Barnard has confirmed that iOS 5.1 breaks the settings apps URL schemes.
Update: iOS 8 has similar functionality for opening your app’s settings. Thanks Apple, Mike and Soto_iGhost.
The constant UIApplicationOpenSettingsURLString (UIApplication Documentation) will open the settings for your app and not, say Twitter’s settings. Not exactly the same functionality but much cleaner than before and now officially recognized.
This should be extra useful now that each app has a place in Settings for using privacy, cellular data, background app refresh and notifications.
you can do this.
TWTweetComposeViewController *ctrl = [[TWTweetComposeViewController alloc] init];
if ([ctrl respondsToSelector:#selector(alertView:clickedButtonAtIndex:)]) {
// Manually invoke the alert view button handler
[(id <UIAlertViewDelegate>)ctrl alertView:nil
clickedButtonAtIndex:0];
}
If you look in Twitter's framework (that Twitter view controller), it has "prefs:root=TWITTER" inside, 5.1 also has this line. So probably Apple made something to disable it for other apps, like some special key in plist or method "openURL" somehow checks if it's not a system app.

get the list of application through UIDocumentInteractionController

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.