2013-03-29 98 views
-6

我想在我的应用程序在getinfo()函数中打开iphone官方设置,如果用户已经登录,则不需要打开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"); 
       } 
      }]; 

     } 
+0

苹果不允许在您的应用程序中访问iPhone设置。 – Pratik

+1

关于它的字面意思很多。您花更多时间发布您的问题,然后进行基本的谷歌搜索:https://www.google.com/search?q=open+ios+settings+from+app –

回答

2

正如答案等同一主题的问题说几个:

此功能在iOS的5.0.x版本可用简单:

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

但已经被移除,不再可能。

+1

*标记这样的重复问题,而不是回答他们。* –

+0

@ rohan-patel我确实标记了这个问题,毫无疑问这个问题将会被解决,但同时如果我能够提供一个直接的答案,这将有助于OP。这个网站的首要任务是帮助人们,保持记录清洁第二。 –

+1

我不同意帮助不搜索任何内容并直接发布问题的人。 *回答这样的帮助吸血鬼将鼓励他/她和其他许多人同样要求重复的问题,恕我直言* –

相关问题