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 7572743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:00:08+00:00 2026-05-30T16:00:08+00:00

I have a UIActionSheet that I created Dynamically and it can have a number

  • 0

I have a UIActionSheet that I created Dynamically and it can have a number of buttons from 1 to 5 including cancel button. I can get the cancel button to work fine but lets say that only 2 buttons are need to be added onto the UIActionSheet, lets say they buttons 2 and 4 how do I determine which action to carry out. Cause normally I would use something like.

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
          switch(buttonIndex) {
                 case 0:
                       // Do something here.
                       break;
                 case 1:
                       // Do something else here.
                       break;
                 case 2:
                       // Do something else again.
                       break;
                 case 3:
                       //  Do something else here again.
                       break;
                 default:
                        break;
          }

But if I only add two buttons dynamically there only going to use cases 0, 1. But if I add button 4 as one of the two buttons I still want it to use case 3. Is this possible or is there another way of doing it?

  • 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-30T16:00:10+00:00Added an answer on May 30, 2026 at 4:00 pm

    Use the buttonTitleAtIndex: method to check against the buttons’ titles. You have to take care that your code won’t break if you change a button’s title in one place, though. It’s probably best to save each button’s title in an extra variable when you create the buttons and use this variable to compare with the button titles later.

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

Sidebar

Related Questions

I have a UIActionSheet in my app that defaults to having 4 buttons. If
I have got created a UIActionsheet programatically however I can't figure out how to
I have a UIActionSheet with an undetermined number of buttons. I'll need to use
I have 4 buttons in UIActionsheet from Top to Bottom Sequence is as below
I have a view that has a button which brings up a UIActionSheet pop
yes but i have a problem i have created a controller that inherits from
I have a UIActionSheet that contains buttons that are programmatically added depending on whether
I have a UIActionSheet that I am able to successfully call from a UIBarButtonItem
I have a UIActionSheet that displays various buttons, one of which posts a tweet
I have a UIActionSheet that pops up as soon as the initial view in

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.