Reputation: 5478
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..
Upvotes: 0
Views: 5680
Reputation: 2351
To transition between views you're going to want to read up on UINavigationControllers
. A UINavigationController
is an object that manages a hierarchy of views. The UINavigationController
is 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 methods pushViewController:animated
(to transition to a new view controller) and popViewController: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.UIViewController
you want to transition to and then instruct the UINavigationController
to push this next view controller onto the navigation stack by calling pushViewController:animated:
popViewController:animated
.Here's the class reference for UINavigationController
to get you started. It's got some great pictures explaining it's structure.
Upvotes: 6