将UITableViewController推送到导航堆栈失败

时间:2013-02-01 17:33:51

标签: ios uinavigationcontroller uitabbarcontroller

我的应用程序包含UITabBarController,其中嵌套了一些UINavigationController,以及这些导航控制器中的UITableViewController子类。当我尝试将新创建的UITableViewController推送到现有的导航控制器并且其中包含现有的tableView时,应用程序挂起,而且仪器显示它通过调用{{1}一遍又一遍地分配内容。无论那是什么。

我正在以非常简单的方式推动控制器,只是:

[UIWindow _subtreeMonitorsForView:]

如果我更改它以便我推送普通_orderForm = [[OrderFormViewController alloc] init]; [self.navigationController pushViewController:_orderForm animated:YES]; 而不是表格,它就可以正常工作。也就是说,如果我只是将OrderFormViewController.h文件中的声明从UIViewController更改为UITableViewController,它会显示空白视图,不会挂起。可能是什么问题?

注意,OrderFormViewController.h的内容非常简单,只包含标准的内置函数。我尝试推送UIViewController的另一个子类(用于初始化UITableViewController时工作正常),结果相同 - 应用程序挂起并继续占用内存。

1 个答案:

答案 0 :(得分:1)

我找到了这个以及其他几个类似行为的错误的罪魁祸首。事实上,我在实例化控制器之前在我的app委托中执行此操作:

UIView *bg = [[UIView alloc] initWithFrame:CGRectZero];
bg.backgroundColor = [UIColor whiteColor];
[[UITableView appearance] setBackgroundView:bg];

关于使用[UITableView appearance]的一些内容并不适合使用代码,包括无法在任何变体中使用UIDatePicker(尽管UIPickerView仍在使用,这只会让我感到困惑进一步)。

出于某种原因,整个UIAppearance协议,虽然听起来很有希望,但是有一些问题,这不是我第一次发现它是造成一些奇怪错误的原因。摆脱它使一切都完美无缺。