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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:59:11+00:00 2026-05-30T03:59:11+00:00

Ok I have an application that uses tab controller. However before I want the

  • 0

Ok I have an application that uses tab controller. However before I want the tab controller to load up, I want the user to enter a screen which allows them to enter their phone number first as I need to save the users phone number for use in the application. I save the number to the application like this.

[[NSUserDefaults standardUserDefaults] setInteger:1234 forKey:@"PhoneNumber"];

Basically when they first enter application, a window will open which will allow them to store enter their number in text field and it saved using the NSuserDefaults.

In the appDelegate, I have an if statement to check if a value is stored or not like this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    NSInteger phoneNumber=[[NSUserDefaults standardUserDefaults] integerForKey:@"PhoneNumber"];

    if(phoneNumber == 0){
        //So this is the window which allow them to enter their phone number
        UIViewController *phoneNumberVC = [[PhoneNumberVC alloc] initWithNibName:@"PhoneNumber" bundle:nil];
        UIViewController *phoneNumberRootVC = [[UINavigationController alloc] initWithRootViewController:phoneNumberVC];
        self.window.rootViewController = phoneNumberRootVC;    
        [self.window makeKeyAndVisible];    
    }else{
        //Code here sets up tab controller and all the tabs etc
    }
}

Now the code works fine, except for the fact that after the number is saved, I have to exit the simulator, and run it again, and then the tab screens appear. However, I want the tab controller to load up a soon as the user has pressed the button in the phone number screen to save the number. Current method in the phone number screen is this:

-(IBAction)testing{
    NSString *st = [phoneTF text];
    NSInteger pn = [st intValue];
    NSString *display = [NSString stringWithFormat:@"%i", pn];
    [[NSUserDefaults standardUserDefaults] setInteger:pn forKey:@"PhoneNumber"];
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning"
                                                     message:display
                                                    delegate:self
                                           cancelButtonTitle:@"Okay"
                                           otherButtonTitles:nil];
    [alert show];
}

The alert is just for testing purposes. So after the button is pressed, I want the tab controller to load up in the app delegate. Is there anyway I can refresh the application or the app delegate?

Would be very grateful if someone could point me in the right direction!!!

EDIT

Tried

[self.navigationController pushViewController:app.tabBarController animated:YES];

But as the tabBarController is not initialised yet, it won’t run

Console error

Application tried to push a nil view controller on target <UINavigationController: 0x8056d40>.

So I need to run the AppDelegate again, so the tab controller and all its views will be initialised

  • 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-30T03:59:12+00:00Added an answer on May 30, 2026 at 3:59 am

    replace

    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:display
                                                delegate:self cancelButtonTitle:@"Okay" otherButtonTitles: nil];
    [alert show];
    

    with code that asks the navigation controller to switch to the other view you want:

    YourOtherViewController *yourOtherViewController = [[YourOtherViewController alloc] init];
    [self.navigationController pushViewController:yourOtherViewController animated:YES];
    

    Edit

    If you want to access the AppDelegate from phoneNumberVC, you can do something like the following:

    if(phoneNumber == 0){
        UIViewController *phoneNumberVC = [[PhoneNumberVC alloc] initWithNibName:@"PhoneNumber" bundle:nil];
        phoneNumberVC.appDelegate = self; // add this property to PhoneNumberVC
        UIViewController *phoneNumberRootVC = [[UINavigationController alloc] initWithRootViewController:phoneNumberVC];
        self.window.rootViewController = phoneNumberRootVC;
    } else {
        [self setUpTabViewController]; // add this function
    }
    [self.window makeKeyAndVisible];
    

    And in PhoneNumberVC something like:

    [self.appDelegate setUpTabViewController];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that uses a dual monitor setup - User A will
I have an application that uses a tab bar and whenever it launches it
I have an application that uses a UITabBarController as its outer container. Each tab
I have an application that uses a UITabBarController, and inside each tab I have
I have a screen that uses tabs in my android application. There is a
I have a Silverlight 4 application that uses multiple tabs. On Tab 1 I
I have a gwt application which uses the slider of smartgwt. However, it takes
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have client application that uses WCF service to insert some data to backend
I have an application that uses the accelerometer. Sometimes, the application will launch without

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.