I am trying to create something to list all the Twitter user accounts connected to the device in UIActionSheet. For example, I have three Twitter accounts on my device. I would like the action sheet to list my accounts with a cancel button. Currently my function looks like this:
- (void)showAlertViewForAccounts:(NSArray*)accounts {
accounts = _.arrayMap(accounts, ^id(ACAccount *account) {
return account.username;
});
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose an account:"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (NSString *username in accounts) {
[actionSheet addButtonWithTitle:username];
}
[actionSheet showInView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view]];
}
My problem is that the cancel button does not appear in a separate “section” of the action sheet.
In any case, I can A.) convert the array accountsto va_list, which should be passed as a parameter of the method UIActionSheet init..., or B.) indicate that the cancel button should be displayed in a separate "section"?