您没有提供太多上下文,因此我假设此错误发生在启动时,因为您正在呈现密码视图控制器。
为了摆脱这个警告,我将应用程序委托注册为导航根视图控制器的委托:
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
((UINavigationController *)self.window.rootViewController).delegate = self;
return YES;
}
然后我将模态视图控制器呈现在navigationController:didShowViewController:animated:
一个dispatch_once
:
- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
static dispatch_once_t once;
dispatch_once(&once, ^{
KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init];
passcodeController.delegate = self;
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController];
[(UIViewController *)self.delegate presentViewController:passcodeNavigationController animated:YES completion:nil];
});
}
由于navigationController:didShowViewController:animated:
在根视图控制器确实出现后调用,因此对开始/结束外观转换警告的不平衡调用消失了。