我目前需要在返回主菜单之前显示登录屏幕,然后是其他屏幕。
目前,我检查是否有人登录主菜单,然后呈现模态登录视图(在UINavigationController内),如果没有。 然后,用户填写登录详细信息并单击“提交”。但在返回主菜单(现已登录)之前,我需要再展示两个屏幕来显示一些选项。
我不确定使用哪种结构。当用户点击提交按钮时,我想到将选项屏幕推到堆栈上。但是,一旦完成该屏幕并弹回到根(登录)视图控制器,有没有办法自动解除模态视图,或者我应该以另一种方式构建它?
感谢。
答案 0 :(得分:1)
您可以在UINavigationController中推送登录屏幕,并使用此控制器推送您的其他登录后屏幕。
// create and add your view controller to a navigation Controller
LoginController *loginController = [[LoginController alloc] init];
UINavigationController *navigationController = [UINavigationController alloc] initWithRootController:loginController];
// present it modally
[self presentViewController:navigationController animated:YES];
用户完成最后一个帖子登录屏幕后,在navigationController上调用dismissViewController将返回主屏幕。
[self.navigationController dismissViewControllerAnimated:YES];
答案 1 :(得分:0)
这样做的最佳方法是在您使用导航控制器的app委托中以模态方式呈现它,只需在此处初始化您的登录视图,然后从导航控制器以模式方式显示它,如下所示。
[self.navigationController presentModalViewController:loginView animated:yes];
并在您的登录视图中使用
[self.navigationController dismissViewController animated:YES];