I have a Login view in my iPhone app. If the user successfully authenticates I want to move him from LoginViewController screen to MyViewController screen. Below is my code,
if([serverOutput isEqualToString:@"Yes"]){
NSLog(@"Authentication correct");
if(self.myviewController==nil)
{
MyViewController *myController=
[[MyViewController alloc]initWithNibName:@"MyView" bundle:[NSBundle mainBundle]];
self.myviewController=myController;
[myController release];
}
}
But somehow the app doesnt do anything when i click on the Login button even though the authentication is correct. As i am new to iphone app development can anybody please help me out with the code..
To transition between views you’re going to want to read up on
UINavigationControllers. AUINavigationControlleris an object that manages a hierarchy of views. TheUINavigationControlleris like a road map for going from one view to another in your applications flow and it achieves it’s most basic features by calling the methodspushViewController:animated(to transition to a new view controller) andpopViewController:animated(to transition back to the preview view).In the case of your project you’d want to do the following.
UINavigationController(in your application delegate if you plan on the login screen to be where your program starts) and assign it’s root view to your login view controller.UIViewControlleryou want to transition to and then instruct theUINavigationControllerto push this next view controller onto the navigation stack by callingpushViewController:animated:popViewController:animated.Here’s the class reference for
UINavigationControllerto get you started. It’s got some great pictures explaining it’s structure.