Note that there are some explanatory texts on larger screens.

plurals
  1. POUIActionSheet long list behavior changed in 4.2?
    text
    copied!<p>I am seeing some changed behavior in iOS 4.2 with UIActionSheet. I can't find anything in Apple's developer docs or forums about it, so I'm not sure how to resolve it.</p> <p>In my list app, I present the user with an actionsheet from which she can pick the list she wants to load on startup. Obviously that means there will be a variable number of items, and the control handles it fine. Until about 7 items, it shows all items as buttons. Once it crosses that threshold, it puts the items into a scroll view to choose from. Until 4.2, it included the Cancel button in that scrolling list. In 4.2, it now seems to be separating the Cancel control, leaving it as a button while putting the rest of the items into the scroll view. The problem is that it appears that it keeps the Cancel item in the list of button indices, so that when I inspect the buttonTitleAtIndex:buttonIndex in either clickedButtonAtIndex: or didDismissWithButtonIndex:, the first item returns "Cancel", then the other item titles are off by 1. Clicking the Cancel button also returns "Cancel".</p> <p>Anyone else experienced this and have a suggestion for how to handle it? Again, this worked fine in 3.0, 3.1, 4.0, and 4.1. </p> <p>Here's the relevant code I'm using:</p> <pre><code>- (IBAction)popupDefaultListActionSheet { UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil]; for (List *l in allActiveLists) { // allActiveLists defined elsewhere [popup addButtonWithTitle:[l label]]; } popup.actionSheetStyle = UIActionSheetStyleBlackOpaque; popup.tag = 23; [popup becomeFirstResponder]; [popup showInView:[self.view.window.subviews objectAtIndex:0]]; [popup release]; } - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { DLOG(@"AppSettingsVC.actionSheet didDismissWithButtonIndex: %d", buttonIndex); NSString *defaultListName = [actionSheet buttonTitleAtIndex:buttonIndex]; DLOG(@"chosen default list was: %@", defaultListName); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload