How to open preferences/settings with iOS 5.1?

前端 未结 4 1506
日久生厌
日久生厌 2020-11-27 15:32

Looks like iOS 5.1 has broken the standard URL encoding for navigating a user to a Preference.

For example:

[[UIApplication sharedApplication] openUR         


        
相关标签:
4条回答
  • 2020-11-27 15:46

    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];
        }
    }
    
    0 讨论(0)
  • 2020-11-27 15:46

    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];
                        }
    
    0 讨论(0)
  • 2020-11-27 16:05

    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.

    0 讨论(0)
  • 2020-11-27 16:07

    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.

    0 讨论(0)
提交回复
热议问题