pushViewController为导航栏设置动画,但不会显示新视图 [英] pushViewController animates the navigation bar but the new view doesn't show up

查看:50
本文介绍了pushViewController为导航栏设置动画,但不会显示新视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS应用程序正在做一些疯狂的事情...我会尽力描述它.

I've got an iOS app that is doing some crazy stuff... I'll do my best to describe it.

我的导航架构如下:

AppDelegate调用此:

AppDelegate calls this:

tabNavController = [[MainTabViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = tabNavController;
[self.window makeKeyAndVisible];

MainTabViewController继承自 UITabBarController

MainTabViewController inherits from UITabBarController

在MainTabViewController的viewDidLoad中,我以编程方式将标签加载到NSMutableArray中,并将其分配给tabControllers:

Inside MainTabViewController's viewDidLoad, I programmatically load my tabs into an NSMutableArray and assign it to the tabControllers:

NSMutableArray *tabs;

StreamViewController *controller = [StreamViewController alloc] initWithNib...];
UINavigationController *navCon = [UINavigationController alloc] initWithRootViewController:controller];

[tabs addObject:navContorller];

...
self.viewControllers = tabs;

我的第一个标签-默认显示的标签-继承自UIViewController.我在XIB中有一个UITableView设置作为主视图.我的课程是UITableViewDelegate和UITableViewDataSource.

My very first tab -- the one that is displayed by default -- inherits from UIViewController. I have a UITableView setup in a XIB as the main view. My class is the UITableViewDelegate and UITableViewDataSource.

StreamViewController : BaseModuleViewController <UITableViewDelegate, UITableViewDataSource>

该表加载并显示正常.当用户单击一行时,我将一个新的视图控制器推入堆栈:

The table loads and displays fine. When a user clicks a row, I push a new view controller to the stack:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {    
   ...
   DetailViewController* detailController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
   [self.navigationController pushViewController:detailController animated:YES];
   ...
}

这是很奇怪的地方.视图控制器的行为就像它要显示的那样,但事实并非如此.我看到我的navigationBar动画了-我的按钮移动了,标题改变了,并且显示了后退"按钮-但是视图本身没有显示.我什至可以继续单击表格视图单元格并不断加载越来越多的视图,每个新视图都会为导航栏设置动画,并显示一个新的后退按钮.然后,我可以回击X次以返回"我的StreamViewController.

This is where it gets strange. The view controller acts like its going to display, but it doesn't. I see my navigationBar animate -- my buttons shift around, the title changes, and a Back button shows up -- but the view itself does not display. I can even continue to click the table view cells and continually load more and more views, each new one animates the navbar and shows a new back button. I can then hit back X number of times to get "back" to my StreamViewController.

这是下一个击球手.如果我导航至选项卡#2,然后返回至选项卡#1,则上述所有操作均不会发生,并且该视图将显示为应有的样子.

Here's the next kicker. If I navigate to tab #2, then back to tab #1, none of the above happens and the view appears exactly like it should.

奇怪-有人看到过这个,对发生的事情有一个想法吗?

Strange - anyone seen this and have an idea of what's going on?

编辑

以下是一个YouTube视频,显示该视频无法正常工作: http://youtu.be/Shces88d6Go

Here's a YouTube video showing it not working: http://youtu.be/Shces88d6Go

推荐答案

发现我正在MainTabViewController的viewDidLoad方法中启动模式窗口.这在某种程度上使系统感到困惑,并且是问题的根源.

Found that I was launching a modal window in the viewDidLoad method of my MainTabViewController. This somehow confused the system and was the root of the problem.

这篇关于pushViewController为导航栏设置动画,但不会显示新视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆