从app委托模态视图呈现不平衡调用开始/结束外观

时间:2011-12-15 14:30:04

标签: iphone objective-c uitabbarcontroller modalviewcontroller uiapplicationdelegate

这是我用来在应用首次启动时呈现模态视图的代码

- (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;

}

这就是日志所说的

Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x171320>.

有没有更好的方法来实现这一目标?

此外,我的app appate

中也有此方法
    -(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;
    }
}

基本上我的tabbarcontroller上的一个选项是注销按钮。上面的代码工作正常,不会向日志发出警告。

1 个答案:

答案 0 :(得分:0)

为什么要从标签栏控制器中显示它?假设您的上述代码来自UIViewController,请尝试

[self presentModalViewController:security animated:YES];

[self.navigationController presentModalViewController:security animated:YES];