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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:32:05+00:00 2026-05-17T00:32:05+00:00

-(void)alertOKCancelAction { // open a alert with an OK and cancel button UIAlertView *alert

  • 0
-(void)alertOKCancelAction 
{
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Return Home" message:@"Are 
    you sure you want to return to the menu?" delegate:self cancelButtonTitle:@"Cancel"  
    otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}

-(void)alertConnectionLost 
{
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Lost"
    message:@"The connection to the other device has been lost" delegate:self  
    cancelButtonTitle:nil otherButtonTitles:@"OK", nil];    
[alert show];
[alert release];
}


- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{

}
else
{
    [self.parentViewController dismissModalViewControllerAnimated:YES];
}
}

As you can see above, I have 2 alerts. But they both call the same method to handle there key presses. How can I tell which alert is currently alive and respond to the keypresses differently depending on which alert is up?

  • 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-17T00:32:05+00:00Added an answer on May 17, 2026 at 12:32 am

    Use: [alert setTag:1]; and [alert setTag:2]; respectively

    then you can do:

    if([actionSheet tag] == 1){
      //do thing for first alert view
    }
    else if([actionSheet tag] == 2){
      //do something for second alert view
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

- (void)fadeOutSplash { UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@Default-Landscape~ipad.png]]; [self.window.rootViewController.view addSubview:splash]; // <--
- (void)showMusicPlayer { [MediaPlayController releaseInstance]; MusicPlayController *musicPlayController = [[MusicPlayController alloc] init]; MusicPlayerViewController *musicPlayerViewController =
- (void)viewDidLoad { [super viewDidLoad]; ac = [[AddContacts alloc]init]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:ac];
void* myfunction() { char *p; *p = 0; return (void*) &p; } I know
- (void)viewDidLoad { webCollectionOnScroller=[[NSMutableArray alloc] init]; scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
-(void)setUserFilters{ //init the user filters array userFilters = [[NSMutableArray alloc] init]; SearchCriteria *tmpSc= [[SearchCriteria
- (void)main { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Warning goes here NSRunLoop
- (void)viewDidLoad { [super viewDidLoad]; definedNames = [[NSArray alloc] initWithObjects:@Ohio, @Newark, @Steve, @Coffee, nil];
-(void)setX:(int)x andY:(int)y andObject:(Sprite*)obj { [obj setPosition:CGPointMake(x,y)]; } Now, I want to call above method,
- (void)viewDidLoad{ UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; [self.view addSubview:baseView]; //

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.