- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
Apple 的文档中提到 indexPath
参数:
The index path specifying the location of the cell. The data source receives this information when it is asked for the cell and should just pass it along. This method uses the index path to perform additional configuration based on the cell’s position in the table view.
但是 register(Class|Nib):forCellReuseIdentifier:
只指定要使用的重用标识符,而不是部分或一组索引路径。
我想也许 UITableViewCell
有某种方法可以获取索引路径,所以它可以,比如说,如果在一个部分的第一行,就可以绕过它的角落,但我没有看到它。在创建时,它得到的只是它的样式和重用标识符 (initWithStyle:reuseIdentifier:
);在重用时,它只被告知 prepareForReuse
。
鉴于旧的 dequeueReusableCellWithIdentifier:
仍然受支持,如果它不能依赖有机会这样做的话,它可能正在做什么样的基于索引路径的配置,无论如何?
我查看了 Table View Programming Guide,但它自 iOS 5 以来一直没有更新。
最佳答案
dequeueReusableCellWithIdentifier:
和dequeueReusableCellWithIdentifier:indexPath:
之间最重要的区别是它们是不同的方法!因此他们可以有不同的行为,他们也确实如此。这与 indexPath 无关,真的;我们只需要一种方法来区分它们。
特别是,如果您调用 dequeueReusableCellWithIdentifier:indexPath:
,这表明您正在使用新的 iOS 6 注册和出列系统。所以,如果你没有注册这个标识符,你会得到一个很好的崩溃和解释问题的日志消息。这个方法永远不会返回 nil;它总是返回一个单元格,要么通过创建一个新单元格,要么通过重复使用一个单元格。
另一方面,简单明了的 dequeueReusableCellWithIdentifier:
是旧的,必须向后兼容。如果你还没有注册这个标识符,它不会提示:它只会返回 nil,让你无所适从。你必须自己创建单元格,就像过去的糟糕日子一样。
编辑:但另请参阅@svena 的回答!新方法(使用 indexPath:
)还有第二个我不知道的优势:单元格在返回给您时大小正确。
关于ios - dequeueReusableCellWithIdentifier :forIndexPath: get used?的indexPath在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12714737/
我有一个使用 NSLayoutConstraints 的自定义/子类 UITableViewCell。最左边的 UIImageView 可能填充也可能不填充图像,如果没有,则此字段右侧的对象自然会向左
我知道 dequeueReusableCellWithIdentifier:forIndexPath 是由 tableviewcontroller 中的 tableView 方法调用的。如果我理解正确
所以我正在为我的学校制作一个 RSS 阅读器并完成代码。我运行了测试,它给了我这个错误。这是它引用的代码: - (UITableViewCell *)tableView:(UITableView *)
我在这里阅读了很多关于在不同问题中重用表格单元格的内容。 我实现了 UITableview 的子类(在 Swift 中) 在我的 ViewController 的 ViewDidLoad() 中注册了
所以我正在为我的学校制作一个 rss 阅读器并完成了代码。我运行了测试,它给了我这个错误。这是它所指的代码: - (UITableViewCell *)tableView:(UITableView *
我有一个UIViewController嵌入导航 Controller ,嵌入页面 View Controller 。在我的cellForRowAtIndexPath ,我得到2015-07-06 1
我不能像使用 UITableView 那样任意出列单元格来计算高度。使用 UICollectionView 执行此操作的等效方法是什么? dequeueResuableCellWithReuseIde
我想知道是否有人遇到过我最近试验过的类似问题。 让我进一步描述一下我的问题。我有一个 UITableViewController,我在 IB 中设计了一组自定义 UITableViewCell。每个
拥有一个UITableViewController并使用: override func tableView(tableView: UITableView, cellForRowAtIndexPat
我在尝试将 addSubView() 放入 UITableViewCell 时收到此错误消息 错误信息 2015-05-18 11:26:46.048 xxxxx[1128:437863] * Ass
我已阅读 this question并认为我理解这两种方法之间的区别,直到我找到一个奇怪的例子: 在Storyboard中设置table view cell的样式为Basic,Identifier为C
由于某种原因,我的应用程序在尝试将单元格加载到表格 View 时失败。我在整个应用程序中的所有表格 View 都完全相同,我对它们没有任何问题。这可能与从另一个 viewController 初始化
我是 xcode 的新手,我正在尝试使用自定义单元格在 tableview 中显示一些数据,但我得到了 *** Assertion failure in -[UITableView _configur
谁能告诉我为什么会出现此错误? 这是我的 .m 文件: #import "ListaParticipantesViewController.h" #import "Participantes.h" #
我在我的项目中使用tableview apple 的延迟加载代码,但在项目中出现异常。错误是 - *** Assertion failure in -[UITableView _configureCe
查看其他类似问题后,我不确定错误出在哪里。我收到了一个断言失败。 Terminating app due to uncaught exception 'NSInternalInconsistencyE
我在尝试填充我的表时遇到此错误: * Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath
这是我的 UITableView 代码。每当我加载 View 时,都会收到以下错误: *** Assertion failure in -[UITableView _configureCellForD
我在 tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCel
Apple 的文档中提到 indexPath 参数: The index path specifying the location of the cell. The data source recei
我是一名优秀的程序员,十分优秀!