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

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.

Related

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] ;
}

iOS 6 Social framework not going to settings or no alert

I'm trying to implement the new social framework in iOS6, and have it working, except for 2 weird problems. If I've enabled the services I'm interested in (say... FaceBook), then it works fine. However, if the accounts are deleted from the settings panel (let's say FaceBook, to be consistent), then I get differing, and frustrating behaviors in the simulator and the device.
Here's the relevant code in my view controller:
//Method for FaceBook
- (IBAction)doFacebook:(id)sender{
//check to see if facebook account exists
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
// Create the view controller defined in the .h file
fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
// make the default string
NSString *FBString= [NSString
stringWithFormat:#"%#\r via #GibberishGenerator", gibText.text];
[fb setInitialText:FBString];
// show the controller
[self presentViewController:fb animated:YES completion:nil];
}
}
And here's the weird behavior when firing off the above method:
In the simulator (version 6.0 (358.4) I get the dialog informing me that I haven't set up any faceBook accounts with "Settings" and "Cancel" buttons. Hitting "Settings" just dismisses the dialog, but doesn't take me to the settings panel.
On my iPhone 4s running 6.01, hitting the button that triggers the method results in... nothing. In other words, I get no dialog informing me that I have to set up a FaceBook account.
Thanks in advance for your help.
OK... Here's the fix:
Here's my new implementation, based on user1734802's helpful comment.
//Method for FaceBook
- (IBAction)doFacebook:(id)sender{
// Create the view controller defined in the .h file
fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
// make the default string
NSString *FBString= [NSString
stringWithFormat:#"%#\r via #GibberishGenerator", gibText.text];
[fb setInitialText:FBString];
// show the controller
[self presentViewController:fb animated:YES completion:nil];
}
At some point I expect
[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
to actually work correctly (triggering the automatic dialog, and taking you to settings), so I actually just commented it out in my code.
I had the same problem, i fixed it by removing the If statement:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
Then the view will display although there is no Facebook/Twitter account configured in the settings.
And the "No Facebook/Twitter accounts" alertView showed! And I was able to hit the "Settings" button on the alert, and it directed me to the settings (Configure Facebook/Twitter account in the settings)
This is the code I used, and it works perfectly for me:
- (IBAction)bTwitter:(id)sender {
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[mySLComposerSheet setInitialText:#""];
[mySLComposerSheet addImage:[UIImage imageNamed:#""]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}

UIDocumentInteractionController no longer works in iOS6

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.

Problem when adding Three20 PhotoViewer to my UINavigationViewController

I want a photo viewer in my iphone app and I liked the Three20 photo viewer. I found it somehow hard to integrate it in my own app where I have my typical UINavigationViewController. So far I succeeded in doing the following:
TTURLMap *map = [[[TTURLMap alloc] init] autorelease];
[map from:#"tt://appPhotos" toSharedViewController:[PhotoViewController class]];
[self.navigationController pushViewController:[map objectForURL:#"tt://appPhotos"] animated:YES];
The only problem is that wenn I click back to my original view, its navigation bar keeps the style of the photo viewer (transperant and shows the view under it).
How can I get back my original navigation bar?
My experience: I once used three20's PhotoViewer and every time I went back from the PhotoViewer to my other view. The system status bar remained black and transparent (while it should be with default style). I solved it by manually and programmatically changing the status bar style every time when the back action was triggered.
Yes, this is a bit of an issue for sure. A good solution, as #diwup says, is to implement a manual fix. I tend to subclass TTPhotoViewer when I need it. Not only does it help with this problem but it also makes it much easier to use I find.
If you decide to subclass, then you should use whatever variation of the following you require:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.tintColor = myTintColor;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
However, if you don't want to subclass, you can always put the code into the - [viewWillAppear:] method of any class that comes after the photo viewer.

iOS4 ABNewPersonViewController Loses Data Entered when attempting to add a Photo iPhone 4

I have implemented a basic add contact feature to an iOS 4 application. Following the documentation from Apple, I have created a navigation controller, and set its root view to the ABNewPersonViewController. I have implemented the delegate as well. The basic mechanics all work.
The problem I am having is when you add a photo to the new person that is very large (taking a photo or picking one from the library), the ABNewPersonViewController form returns empty when the camera controls are dismissed. No photo is in the add photo box either. If I pick a small image (say a screenshot from the iPhone), everything works. I can see from the debug output: Received memory warning. Level=1
Has anyone else run into this? Is there a way to set the photo quality to a lower setting for the ABNewPersonViewController? Any help appreciated.
ABNewPersonViewController *abNewPersonView = [[ABNewPersonViewController alloc] init];
abNewPersonView.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [UINavigationController alloc];
[newNavigationController initWithRootViewController:abNewPersonView];
[self presentModalViewController:newNavigationController animated:YES];
[abNewPersonView release];
[newNavigationController release];
If ABNewPersonViewController does not handle memory warnings correctly, file a bug with apple.