iphone ipad uitabbarcontroller transitions

iphone - Llamadas desequilibradas para comenzar/finalizar transiciones de aparición para UITabBarController



ipad transitions (5)

Debe esperar para presentar el controlador de vista modal hasta el siguiente ciclo de ejecución. Terminé usando un bloque (para hacer las cosas más simples) para programar la presentación para el siguiente ciclo de ejecución:

Actualizar:
Como menciona Mark Amery a continuación, solo funciona un simple dispatch_async , no hay necesidad de un temporizador:

dispatch_async(dispatch_get_main_queue(), ^(void){ [self.container presentModalViewController:nc animated:YES]; });

/* 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]; });

Tengo un UITabBarController, cuando se ejecuta por primera vez, quiero superponer un controlador de vista de inicio de sesión pero recibí un error.

Llamadas no balanceadas para comenzar / finalizar transiciones de aparición para <UITabBarController: 0x863ae00>.

A continuación está el código.

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

¿Alguien que pueda ayudarme? ¡Gracias por adelantado!


Sospecho que el problema es que estás tratando de llamar a presentModalViewController: antes de que la barra de pestañas termine de cargarse. Intenta mover la lógica final al siguiente ciclo de eventos:

[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); } }


Tuve un problema similar cuando intenté presentarModalViewController (mi pantalla de bienvenida) en la vista principalWillAppear. Se resolvió simplemente moviendo la llamada modal de VC a viewDidAppear.


[self performSelector:@selector(modaltheView) withObject:self afterDelay:0.1]; -(void)modaltheView { [self.container presentModalViewController:nc animated:YES]; }


[self.tabBarController presentModalViewController:loginVC animated:**NO**];