如何从我自己的应用程序打开iPhone设置?

时间:2013-03-29 06:48:31

标签: iphone objective-c cocoa-touch xcode4

我想在getinfo()函数中从我的应用程序打开iphone官方设置,如果用户已登录,则无需打开iphone的官方设置,如果没有用户登录应用程序打开官方设置目前iphone无法打开iphone设置。

 - (IBAction)twitterLogin:(id)sender {

        [self getInfo];

    }

        - (void) getInfo
        {
            // Request access to the Twitter accounts

            ACAccountStore *accountStore = [[ACAccountStore alloc] init];
            ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

            [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
                if (granted) {
                    GET_DEFAULTS
                    [defaults setInteger:1 forKey:kHasUserRemembered];
                    [defaults synchronize];
                     NSArray *accounts = [accountStore accountsWithAccountType:accountType];

                    ACAccount *twitterAccount = [accounts objectAtIndex:0];
                    GET_DBHANDLER
                    NSDictionary *tempDict = [[NSMutableDictionary alloc] initWithDictionary:
                                              [twitterAccount dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]]];
                    NSString *tempUserID = [[tempDict objectForKey:@"properties"] objectForKey:@"user_id"];

                    NSLog(@"userid: %@", tempUserID);
                    userDC *user =  [dbHandler authenticate_User:twitterAccount.username andPassword: @"" andIsFB:0 AndIsTwitter:1];
                    [defaults setObject:tempUserID forKey:kHastwitterID];
                    [defaults synchronize];
                    [self gotoMainView];






                                   }
               else {


                 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];

                    NSLog(@"No access granted");
                }
            }];

        }

1 个答案:

答案 0 :(得分:2)

正如在同一主题的几个SO问题的答案中所述:

此功能在iOS 5.0.x中简要提供:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

但此后已被删除,不再可能。

相关问题