如果我访问 Twitter,我更愿意使用自动警报框,要求用户转到设置,但无法让它工作并提供我自己的默认对话框,我真的不想这样做。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"indexPath.row %i", indexPath.row);
if (indexPath.row == 0) {
store = [[ACAccountStore alloc] init]; // Long-lived
twitterType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[store requestAccessToAccountsWithType:twitterType withCompletionHandler:^(BOOL granted, NSError *error) {
if (granted) {
// Access has been granted, now we can access the accounts
twitterAccounts = [store accountsWithAccountType:twitterType];
if (twitterAccounts.count == 1) {
[self getTwitterData:[twitterAccounts objectAtIndex:0]];
} else {
[self selectTwitterAccount];
}
} else {
// Prefer NOT to do this ************************************
[self performSelectorOnMainThread:@selector(showTwitterError) withObject:nil waitUntilDone:NO];
}
}];
}