我正在尝试在我的 Today 扩展中使用 UITableView。我想,这是大多数人想要做的。当我运行扩展时,numberOfSectionsInTableView
被调用,numberOfRowsInSection
被调用,但 cellForRowAtIndexPath
从未被调用,因此 TableView 永远不会显示。有没有其他人在今天的扩展中成功使用表格 View ?
最佳答案
tableView 总是想知道它有多少行/节,但通常只会在即将显示一个单元格时询问单元格。
tableView 不会请求它无法显示的单元格,特别是当 tableView 没有高度时。
确保您的 ViewController 和 TableView 都具有非零区域框架!
If a widget has additional content to display, you can rely on Auto Layout constraints to adjust the widget’s height as appropriate. If you don’t use Auto Layout, you can use the UIViewController property preferredContentSize to specify the widget’s new height.
关于iOS 今日扩展 : cellForRowAtIndexPath never called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25272725/