【问题标题】:how to open iPhone Setting from my own app? [duplicate]如何从我自己的应用程序中打开 iPhone 设置? [复制]
【发布时间】:2013-03-19 21:18:36
【问题描述】:

如果用户已经登录,我想在 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");
                }
            }];

        }

【问题讨论】:

标签: iphone objective-c cocoa-touch xcode4


【解决方案1】:

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

此功能在 iOS 5.0.x 中短暂可用:

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

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

【讨论】:

  • 标记此类重复的问题,而不是回答它们。
  • @rohan-patel 我确实标记了它,毫无疑问,这个问题将被关闭,但与此同时,如果我能提供一个对 OP 有帮助的直接答案,我会的。这个网站的首要任务是帮助人们,保持记录干净是第二位的。
  • 我不同意帮助那些不搜索任何内容并直接发布问题的人。 回答此类帮助吸血鬼将鼓励他/她和许多其他人同样提出重复的问题,恕我直言
  • @rohan-patel 您有权发表自己的意见。但我问,你担心什么?如果我们不故意不回答他的问题来教他自给自足,那么他是否就不会学会自给自足?如果是这样的话,那么我说我们是谁来管理某人如何学习或不学习。如果您担心网站的混乱,正如我已经说过的,您不必担心,问题将在适当的时候关闭并删除。这两种情况都与您的“否决票”无关,我认为这是不合理的。我认为 OP 会发现我的回答很有用。
猜你喜欢
  • 2012-05-17
  • 2010-09-27
  • 2014-10-01
  • 2013-03-18
  • 2013-03-02
  • 2014-05-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多