Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:47:35+00:00 2026-05-18T21:47:35+00:00

I am seeing some changed behavior in iOS 4.2 with UIActionSheet. I can’t find

  • 0

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.

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”.

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.

Here’s the relevant code I’m using:

- (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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:47:36+00:00Added an answer on May 18, 2026 at 9:47 pm

    Try adding the cancel button dynamically at the end instead of setting it up initially:

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"My Action Sheet"
                                                             delegate:self
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];
    
    for (I32 i = 0; i < itemCount; i++) {
        [actionSheet addButtonWithTitle:itemText];
    }
    
    [actionSheet addButtonWithTitle:@"Cancel"];
    [actionSheet setCancelButtonIndex:itemCount];
    

    Seems to work correctly in iOS 4.2 for us at least.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am seeing some rather weird behavior with PowerShell, it looks like custom functions
I always believe they did, but seeing some answers here make me doubt... Can
I'm seeing some weird behavior in php when comparing a double to a string
I'm seeing some errors that would indicate a connection leak. That is, connections that
I'm seeing some code I've inherited that looks like the following: @interface SomeClass (private)
I'm new to PHP and I'm confused seeing some examples calling a function with
I am developing an OpenGL application and I am seeing some strange things happen.
I've got a simple MVC (RC1) app set up, and I'm seeing some odd
I've been working with some C# legacy code and I've been seeing a lot
I've been seeing some strange issues using the Alarm manager in Android, despite the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.