我是一个新手 ios 开发人员,我有一个关于如何向登录页面添加视图的问题。目前我有一个登录页面,我想做的是在登录页面可见之前,另一个模式视图应该在它之前,用户必须首先关闭它。我怎样才能在xcode中添加这个?
问问题
142 次
1 回答
1
这是展示视图控制器的几个选项。
- (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];
}
然后关闭视图控制器使用这个:
- (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];
}
于 2012-09-07T17:25:59.907 回答