[英]presenting modal view from app delegate unbalanced calls to begin/end appearance
This is the code I'm using to present a modal view when the app first starts 这是我在应用程序首次启动时用于呈现模式视图的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
Security *security = [[Security alloc] initWithNibName:@"Security" bundle:nil];
[self.tabBarController.selectedViewController presentModalViewController:security animated:YES];
[security release];
return YES;
} }
This is what the log says 这就是日志所说的
Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x171320>.
Is there a better way to achieve this? 有没有更好的方法来实现这一目标?
Also I have this method in my app delegate 我的应用程序委托中也有这种方法
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if (viewController == [tabBarController.viewControllers objectAtIndex:2]) {
//The Log Out tab locks the app by presenting a modalviewcontroller that can't be dismissed unless there is a password.
Security *security = [[Security alloc] initWithNibName:@"Security" bundle:nil];
[self.tabBarController presentModalViewController:security animated:YES];
[security release];
return NO;
} else {
return YES;
}
}
Basically one of the options on my tabbarcontroller is a logout button. 基本上,我的tabbarcontroller上的选项之一是注销按钮。 The above code works fine and doesn't throw a warning to the log. 上面的代码可以正常工作,并且不会向日志发出警告。
Why are you presenting it from your tab bar controller? 为什么要从标签栏控制器中显示它? Assuming your above code is from a UIViewController, try 假设上面的代码来自UIViewController,请尝试
[self presentModalViewController:security animated:YES];
or 要么
[self.navigationController presentModalViewController:security animated:YES];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.