【发布时间】: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");
}
}];
}
【问题讨论】:
-
Apple 不允许在您的应用程序中访问 iPhone 设置。
-
确实有很多关于它的问题。您花了更多时间发布您的问题,然后进行了基本的谷歌搜索:google.com/search?q=open+ios+settings+from+app
标签: iphone objective-c cocoa-touch xcode4