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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:15:59+00:00 2026-05-23T08:15:59+00:00

I’m trying to make that when the user press a tabbar item an UIAlertView

  • 0

I’m trying to make that when the user press a tabbar item an UIAlertView gets called, asking if really wants to change the actual tab, the problem is that the UIAlertView doesn’t stop the code until getting the answer, the code keeps running and depending on the previous value change the viewcontroller or not, not the actual.

I’ve tried to wait to the answer with a while, but the screen only gets darker and the alert didn’t popup. I also read this post pause code execution until UIAlertview, I tried but i was unable to make it work, can someone help, thanks!

- (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{

if (([self Myfunction]) && (viewController != [tabBarController.viewControllers objectAtIndex:0])){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"text1" message:@"text2" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
    [alert show];
    [alert release];

    return boolean_var;
}

return YES;}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) [self setBoolean_var:NO];
else [self setBoolean_var:YES];}
  • 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-23T08:16:00+00:00Added an answer on May 23, 2026 at 8:16 am
    - (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
        if ( !([self Myfunction]) || (viewController == [tabBarController.viewControllers objectAtIndex:0])) {
            return YES;
        }
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"text1" message:@"text2" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
        [alert show];
        [alert release];
    
        candidateViewController = viewController; // `candidateViewController` must be declared as an instance variable.
    
        return NO;
    }
    

    Identify which view controller that you need to show alert for and save it in candidateViewController and return NO to delay the switch. Based on the response on the alert view, you should change it.

    - (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
        if (buttonIndex != 0)
            self.tabBarController.selectedViewController = candidateViewController;
    }
    

    The last method assumes few things. Your tab bar controller is referenced by self.tabBarController and that you were setting boolean_var to return it to the earlier method. Alert view is non blocking in that method so using boolean_var is pointless.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but

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.