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

  • SEARCH
  • Home
  • 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 6103527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:44:20+00:00 2026-05-23T13:44:20+00:00

I created two action sheets in one view. There are two buttons, each will

  • 0

I created two action sheets in one view. There are two buttons, each will initiate one action sheet.

The problem: when i press on first choice in both action sheets the same action is triggered.

Here’s my code:

-(IBAction) ChangeArrow:(id)sender{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Change Arrow"
                                                         delegate:self
                                                cancelButtonTitle:@"cancel"
                                           destructiveButtonTitle:@"Red"
                                                otherButtonTitles:@"Blue",@"Black",nil];
[actionSheet showInView:self.view];
[actionSheet release];}
- (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex ==[actionSheet destructiveButtonIndex]) {
    self.bar.image=[UIImage imageNamed:@"red"];

}
else if(buttonIndex == 1){
    self.bar.image=[UIImage imageNamed:@"blue"];

}
else if(buttonIndex == 2){
    self.bar.image=[UIImage imageNamed:@"dark"];}
}

//Second Action sheet:

-(IBAction) Background:(id)sender{
UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Change Background"
                                                         delegate:self
                                                cancelButtonTitle:@"cancel"
                                           destructiveButtonTitle:@"Sky"
                                                otherButtonTitles:@"Thumbs",@"Smiley",nil];
[actionSheet2 showInView:self.view];
[actionSheet2 release];
} 
- (void) actionSheet2: (UIActionSheet *)actionSheet2 didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex ==[actionSheet2 destructiveButtonIndex]) {
    self.background.image=[UIImage imageNamed:@"sky"];

}
else if(buttonIndex == 1){
    self.background.image=[UIImage imageNamed:@"thumbs"];

}
else if(buttonIndex == 2){
    self.background.image=[UIImage imageNamed:@"smiley"];}
}
  • 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-23T13:44:21+00:00Added an answer on May 23, 2026 at 1:44 pm

    Set the tag property on each actionsheet to a different value. Then you can check sender.tag to see which action sheet called your method.

    Ex.

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Change Arrow"
                                                         delegate:self
                                                cancelButtonTitle:@"cancel"
                                           destructiveButtonTitle:@"Red"
                                                otherButtonTitles:@"Blue",@"Black",nil];
    actionSheet.tag = 1;
    UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Change Arrow"
                                                             delegate:self
                                                    cancelButtonTitle:@"cancel"
                                               destructiveButtonTitle:@"Red"
                                                    otherButtonTitles:@"Blue",@"Black",nil];
    actionSheet2.tag = 2;
    

    Then

    - (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
     if(actionSheet.tag == 1) {
         //do something
     } else if(actionSheet.tag == 2) {
         //do something else
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two buttons with pagescrolling. Now by clicking on one button the
I've created two classes, with one of them having an implicit cast between them:
I have created two forms in my Windows Application. One Form acts as a
I have created two JavaScript files. One file is "validators.js" and the other is
I've just created UITableViewCell. I added to it two buttons. Then I set transparent
I have two action methods in my controller class both with same name. One
I made two List actions. One actually corresponds to the default _new action and
I have created two classes that implement AuthorizeAttribute . One is used globally, and
I have created two actions in code, one simple and one advanced. function userbeep_action_info()
I've created a very basic slider with jQuery. There are two arrows called .theleft

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.