ZYi*_*iOS 27 iphone uitabbarcontroller transitions ipad
我有一个UITabBarController,在初始运行时,我想覆盖登录视图控制器但收到错误.
对<UITabBarController:0x863ae00>的开始/结束外观转换的不平衡调用.
下面是代码.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *lessonVC = [[[LessonViewController alloc] initWithNibName:@"LessonViewController" bundle:nil] autorelease];
UIViewController *programVC = [[[ProgramViewController alloc] initWithNibName:@"ProgramViewController" bundle:nil] autorelease];
UIViewController *flashcardVC = [[[FlashCardViewController alloc] initWithNibName:@"FlashCardViewController" bundle:nil] autorelease];
UIViewController *moreVC = [[[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil] autorelease];
UINavigationController *lessonNVC = [[[UINavigationController alloc] initWithRootViewController:lessonVC] autorelease];
UINavigationController *programNVC = [[[UINavigationController alloc] initWithRootViewController:programVC] autorelease];
UINavigationController *flashcardNVC = [[[UINavigationController alloc] initWithRootViewController:flashcardVC] autorelease];
UINavigationController *moreNVC = [[[UINavigationController alloc] initWithRootViewController:moreVC] autorelease];
self.tabBarController = [[[UITabBarController alloc] init/*WithNibName:nil bundle:nil*/] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:lessonNVC, programNVC, flashcardNVC, moreNVC, nil];
self.tabBarController.selectedIndex = 0;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
if (![[ZYHttpRequest sharedRequest] userID])
{
// should register or login firstly
LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
bundle:nil];
loginVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.tabBarController presentModalViewController:loginVC animated:YES];
ZY_SAFE_RELEASE(loginVC);
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
谁可以帮助我?提前致谢!
Mau*_*zio 78
您需要等待呈现模态视图控制器,直到下一个运行循环.我最终使用一个块(使事情更简单)来安排下一个运行循环的演示:
更新:
正如Mark Amery在下面提到的,只是一个简单的dispatch_async工作,不需要计时器:
dispatch_async(dispatch_get_main_queue(), ^(void){
[self.container presentModalViewController:nc animated:YES];
});
Run Code Online (Sandbox Code Playgroud)
/* Present next run loop. Prevents "unbalanced VC display" warnings. */
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.container presentModalViewController:nc animated:YES];
});
Run Code Online (Sandbox Code Playgroud)
Rob*_*ier 10
我怀疑问题是你在presentModalViewController:标签栏完成加载之前试图调用.尝试将最终逻辑移动到下一个事件循环:
[self.window makeKeyAndVisible];
[self performSelector:(handleLogin) withObject:nil afterDelay:0];
}
- (void)handleLogin
{
if (![[ZYHttpRequest sharedRequest] userID])
{
// should register or login firstly
LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
bundle:nil];
loginVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.tabBarController presentModalViewController:loginVC animated:YES];
ZY_SAFE_RELEASE(loginVC);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
[self.tabBarController presentModalViewController:loginVC animated:**NO**];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25400 次 |
| 最近记录: |