iOS: Xcode: How do I switch a view upon launch

I have an iOS application where I'm looking to see if a user has registered yet.  If the user has registered, I want the view to change from the main view to the homepage view upon launch.  Right now, I can't seem to figure out how to check which view is the firstResponder.  Any ideas?
LVL 1
pingeyegAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deepak LakkadCommented:
Hi,

First of all you have to use your "HomePage" as main view (First Responder).

And In "didFinishLaunchingWithOptions", method check if user is not registered then show "Registration" screen.

Here are some code.

In didFinishLaunchingWithOptions method,


self.window.rootViewController = "Your HomePage"
[self.window makeKeyAndVisible];

if(some condition to check whether user is registered or not) {
        // If not Registered
        [self showRegistrationView];
    }

Open in new window


Write a function to show Registration page as below:
- (void)showRegistrationView {
    UIViewController *topViewController = self.window.rootViewController;
    UIViewController *modalViewController = [topViewController modalViewController];
    
    if (![modalViewController isKindOfClass:[HomeViewController class]]) {
        HomeViewController* homeVC = [[HomeViewController alloc] initWithNibName:@"HomeViewController"
                                                                          bundle:nil];
        
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:homeVC];
        
        [topViewController presentModalViewController:navController
                                             animated:NO];
    }
}

Open in new window



The sample code is written from one of my Application.

You have to make correction for your need.


- Deepak Lakkad
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
iOS

From novice to tech pro — start learning today.