UITableView的单元格不加载时的调试策略? [英] Debugging strategies when UITableView's cells don't load?

查看:132
本文介绍了UITableView的单元格不加载时的调试策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将UITableView嵌入到ViewController的主UIView中,该宽度为屏幕宽度的75%.理想情况下,此UITableView也将嵌入到导航控制器中.另外,似乎我无法在iOS 5上使用UIContainerViews,因为遇到错误无法实例化名为UIStoryboardEmbedSegueTemplate的类"(参见 NSInvalidUnarchiveOperationException with ContainerView ).

I am trying to embed a UITableView into my ViewController's main UIView that is 75% the width of the screen. Ideally this UITableView would also be embedded into a Navigation Controller. Also, it seems I cannot use UIContainerViews with iOS 5 because I encounter the error "Could not instantiate class named UIStoryboardEmbedSegueTemplate" (cf. NSInvalidUnarchiveOperationException with ContainerView).

为此,我在ViewController的主UIView中创建了一个UIView,该UIView的宽度为屏幕宽度的75%.在该UIView中,我放置了一个UINavigationBar和一个UITableView.我在ViewController的- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil函数中实例化UITableViewController.实例化后,我通过self.tableViewController.tableView = self.tableView将ViewController的UITableView连接到UITableViewController的UITableView.

To do this, I have created a UIView within my ViewController's main UIView that is 75% the width of the screen. Within that UIView I have placed a UINavigationBar and a UITableView. I instantiate the UITableViewController in the ViewController's - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil function. Once instantiated, I connect my ViewController's UITableView to the UITableViewController's UITableView via self.tableViewController.tableView = self.tableView.

一切似乎都可以正常工作,除了我的UITableView不显示任何单元格,即使我预加载了数据也是如此.

Everything seems to work alright, except that my UITableView isn't showing any cells, even if I preload it with data.

我还可以提供哪些其他数据来帮助诊断问题?我当然没有收到任何错误消息,并且数据源确实收到了数据,并且在数据源更新后我调用了[self.tableView reloadData].

What additional data may I provide to help diagnose the problem? I of course don't receive any error message, and the datasource does indeed receive the data and I call [self.tableView reloadData] after the datasource is updated.

更新1

最终,这是我想要的行为,除了我希望使用多个表视图而不是多个Web视图,每个表视图都嵌入其自己的导航控制器中.我猜测iOS版Chrome浏览器仅会截取网页的屏幕截图(?),因为在滚动标签页时未启用互动功能,但是如果您想保留互动功能,该怎么做?

Ultimately this is the kind of behavior I would like, except that instead of multiple web views I would like multiple table views each embedded in its own navigation controller. I'm guessing that Chrome for iOS just takes a screenshot (?) of the webpage since interaction is not enabled when scrolling through tabs, but how would you do this if you wanted to preserve interaction?

更新2

特定行似乎是CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier],其中static NSString *CellIdentifier = @"New Cell"(并且在IB中定义了适当的原型UITableViewCell).但是,代码似乎并没有在这行崩溃.相反,断点似乎已启动(我未指定)(Thread 1: Breakpoint 1.1).此外,只有在我的iOS设备上进行测试时,才会发生这种情况.通过iOS模拟器进行测试时,一切正常.

The particular line seems to be CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier] where static NSString *CellIdentifier = @"New Cell" (and the appropriate prototype UITableViewCell is defined such in IB). However, the code doesn't seem to crash on this line; instead, a breakpoint seems to be initiated (Thread 1: Breakpoint 1.1) that I did not designate. In addition, this only happens when testing on my iOS device. Everything works fine when testing via the iOS simulator.

推荐答案

您好:我的特定问题的最终答案与iOS 5 v.iOS 6如何处理自动布局有关,尤其是关于UITableViewCells(自动调整子视图") ; cf.,自定义UITableViewCells可以在iOS 6而不是iOS 5上运行的原因有哪些?

Hello: The ultimate answer to my particular problem related to how iOS 5 v. iOS 6 handles autolayout, in particular with regard to UITableViewCells ("Autoresize subviews"); cf., What are some reasons why custom UITableViewCells might work in iOS 6 but not iOS 5?

由于这个特定问题含糊不清,并且答案"与我认为的问题无关,因此我应该投票删除它吗?

Since this particular question is vague and the "answer" doesn't relate to what I thought the problem was, should I vote to delete it?

这篇关于UITableView的单元格不加载时的调试策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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