I am a newbie ios developer and i had a question on how to add a view to a login page. Currently i have a login page and what i want to do is before the login page is visible, another modal view should preceed it that the user must first dismiss. How can i add this in xcode?
Here's a couple options for presenting a view controller.
- (IBAction)goToLoginView:(id)sender
{
//if you are using xibs use this line
UIViewController *controller = [[UIViewController alloc] initWithNibName:@"myXib" bundle:[NSBundle mainBundle]];
//if you are using storyboards use this line
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"myViewControllersID"];
//to present the controller modally use this
[self presentViewController:controller animated:YES completion:nil];
//or if you are pushing to this controller using a navigation controller use this
[self.navigationController pushViewController:controller animated:YES];
}
Then to dismiss a view controller use this:
- (IBAction)closeMyController
{
//if the view was presented modally close it with this
[self dismissViewControllerAnimated:YES completion:nil];
//and to pop back up the navigation stack
[self.navigationController popToRootViewControllerAnimated:YES];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.