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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:10:54+00:00 2026-06-08T21:10:54+00:00

I want two alert views to show up only when the user opens my

  • 0

I want two alert views to show up only when the user opens my application for the first time — the second to appear after the first is dismissed. I have it set up to only show the UIAlertViews when it has not been shown before and I do not need help with this. I need help figuring out how to display two alert views in a row when this is the case.

-(void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex does not work for me.

Here is the code I have — remember this is in didFinishLaunchingWithOptions:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL didFirstLaunch = [defaults boolForKey:@"DidFirstLaunch"];
if (!didFirstLaunch) {
    [defaults setBool:YES forKey:@"DidFirstLaunch"];

    UIAlertView *successAlert = //not important
    [successAlert show];
    [successAlert release];

    //Somehow show second alert after the first is dismissed
}
  • 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-06-08T21:10:55+00:00Added an answer on June 8, 2026 at 9:10 pm

    I’m gonna post a very simple solution using GCD & blocks (GCD part is just in case the alert view is created on another thread then the main thread, callback should be safe to perform on the main thread). Remember, I just coded this in like 5 mins, so you definitely should work on improving the code. One thing that’s a bit ugly is the delegate parameter that is overridden in my subclass. The interface of the subclass could be changed a bit to make it more obvious of what happens …

    Anyway, here goes …

    First create a subclass of UIAlertView, make it look somewhat like the following …

    @interface FSAlertView () <UIAlertViewDelegate>
    
    @property (nonatomic, copy) void (^dismissHandler)(NSInteger buttonIndex);
    
    @end
    
    
    @implementation FSAlertView
    
    @synthesize dismissHandler = _dismissHandler;
    
    - (void)showWithDismissHandler:(void (^)(NSInteger buttonIndex))dismissHandler
    {
        self.dismissHandler = dismissHandler;
    
        self.delegate = self;
    
        [self show];
    }
    
    // Alert view delegate
    
    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
    {
        dispatch_async(dispatch_get_main_queue(), ^ {
    
            if (_dismissHandler)
            {
                _dismissHandler(buttonIndex);
            }
    
        });
    }
    

    Now in the app we can create alert views like the following …

    FSAlertView *alert1 = [[FSAlertView alloc] initWithTitle:@"Alert 1"
                                                     message:@"Some message"
                                                    delegate:nil
                                           cancelButtonTitle:@"Cancel"
                                           otherButtonTitles:@"Show 2nd Alert", nil];
    
    [alert1 showWithDismissHandler:^ (NSInteger buttonIndex) {
    
        NSLog(@"button pressed: %d", buttonIndex);
    
        if (buttonIndex == 1)
        {
            UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Alert 2"
                                                             message:@"Hi!"
                                                            delegate:nil
                                                   cancelButtonTitle:@"OK"
                                                   otherButtonTitles:nil];
            [alert2 show];
        }
    
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show two Dialogs (default) at the same time, no matter if
I have a UITextView and I want have two buttons. When the user taps
I want to run two loops one after the other but it seems the
I have a variable i=28.57142857142857; I want to alert(i); alert this variable on user
I want to iterate over two arrays at the same time, as the values
I have two views. The User view has some text and a button. I
I have two dropdowns and I want the second dropdown to get populated on
I want an alert dialog box to pop up after I click a button
I am new to iPhone developer, i want to compare two Dates, first date
in my Alert View, there is two button, OK and Cancel. When the user

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.