On Button Click go to new scene without using StoryBoard Navigation


#1

My goal is to create a login button that will call a new Scene after the account has been verified to be valid.

Attached below is the screenshot of my Storyboard and the code to open to a Scene.

I did not connect the Login button to the Main App (or the TabView) since when I connect it via navigator, the scene does not verify and goes to the next screen immediately.

I get the error,
2018-02-27 16:14:20.465644+0800 Board Trade[2562:114337] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Pushing a navigation controller is not supported’


#2

I can’t see the screen shot clearly. Can you upload a better one? The error message just says you are pushing a UINavigationController instead of a UIViewcontroller


#3

This is the code that pushes to the new scene

if((userName == inputUsername) && (password == inputPassword)){
    
    UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController];

    [self.navigationController pushViewController:passcodeNavigationController animated:YES];
}

#4

You can’t push a NVC but present it only


#5

UINavigationController push to UINavigationController ?? UINavigationController is just a container, push only viewController


#6

Sorry I am bit slow in understanding a few concepts in IOS.

I found a solution based on @5SMNOOSNM5 hint and found this

if((userName == inputUsername) && (password == inputPassword)){
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UITabBarController *myVC = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"mainPage"];
    [self presentModalViewController:myVC animated:YES];
}

#7

A navigation controller is a container view controller that manages one or more child view controllers in a navigation interface. So the easiest way to understand is using push only for view controller and navigation controller. And present can for any container. But I suggest read Apple Documentation first. Because this is the most important core for build the entire iOS app view structure.


#8

I followed the Apple IOS introduction “Start Developing iOS Apps Today”. I was able to create an initial application. But I have been scrambling from different articles after that.

Ive read iOS App Architecture and Basic Programming Concepts for Cocoa and Cocoa Touch.

Now, im trying to code and come up with an initial application.
The challenge really are the terminologies and how they are implemented.

Ive read KVO, KCC, Objective C but things like delegate, segue, controllers are still vague from my perspective.

Its kinda weird that for UI, you have a screen (scene) then you have navigation which are separate. Then there’s the story board which was really helpful at start but once I wanted to make everything work everything went down hill.