启动应用程序后不出现模态视图
用户必须先登录才能使用我的应用程序。我的想法是,应用程序启动后,登录视图会以模态方式出现。
在 iOS 5 之前,我一直使用 .xib 文件。现在我想将视图转换为情节提要,以便进行概述并更好地使用新功能。
该应用程序与 splitview 控制器配合使用。问题是登录视图已加载,但从未出现。
我在应用程序委托中尝试了它,并为 splitviewcontroller 创建了一个类,并尝试将其加载到 viewDidLoad 中。
代码:
- (void)viewDidLoad
{
[super viewDidLoad];
//load and push login
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
NSLog(@"login push: %@", loginViewController);
[self presentModalViewController:loginViewController animated:YES];
NSLog(@"done push");
}
日志:
2012-01-13 10:18:08.217 App[1101:707] login push: <LoginViewController: 0x472fe0>
2012-01-13 10:18:08.330 App[1101:707] done push
我尝试在根视图或详细视图中加载它,它可以工作,但位置不正确,xcode 给出消息:
2012-01-13 10:18:08.807 App[1101:707] Unbalanced calls to begin/end appearance transitions for <MainSplitViewController: 0x464bc0>.
我的第一个想法是从登录视图开始,登录后推送 splitview 控制器。但我发现 splitview 控制器必须是根视图。
Before the users can use my app the have to login. My idea was that after the app starts the login view appears modally.
Before iOS 5 I had it all working with .xib files. Now I want to convert the views to a Storyboard for overview and better use of the new functionalities.
The app works with a splitview controller. The problem is that the login view is loaded, but never appears.
I tried it in the app delegate and I made a class for the splitviewcontroller and tried to load it in the viewDidLoad.
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
//load and push login
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
NSLog(@"login push: %@", loginViewController);
[self presentModalViewController:loginViewController animated:YES];
NSLog(@"done push");
}
Log:
2012-01-13 10:18:08.217 App[1101:707] login push: <LoginViewController: 0x472fe0>
2012-01-13 10:18:08.330 App[1101:707] done push
I tried to load it in the Root or detail view, it works but its not the right place and xcode gives the message:
2012-01-13 10:18:08.807 App[1101:707] Unbalanced calls to begin/end appearance transitions for <MainSplitViewController: 0x464bc0>.
My first idea is to begin with the login view and after login push the splitview controller. But I found out that the splitview controller has to be the root view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 viewDidLoad 中推送另一个 ViewController 还很早。也许当前的 ViewController 呈现有动画,而您尝试呈现另一个带有动画的 ViewController ...
您应该尝试将 LoginController 的显示移动到 viewDidAppear ...
To push another ViewController in viewDidLoad is very early. Maybe the current ViewController is presented with animation and you try to present another ViewController with animation ...
You should try moving the display of your LoginController to viewDidAppear ...