简体   繁体   English

将UITableViewCell从另一个UITableView出队

[英]Dequeuing a UITableViewCell from a different UITableView

I have a UITableViewCell set up in a Storyboard UITableView that I want to also use in a different UITableView. 我在情节提要UITableView中设置了UITableViewCell,我也想在其他UITableView中使用它。

My current solution is to have a separate nib for the cell and load the bundle in cellForRowAtIndexPath: for both view controllers. 我当前的解决方案是为该单元格提供一个单独的笔尖,然后为两个视图控制器将捆绑包加载到cellForRowAtIndexPath:中。 However, this is messy and I lose a benefit of Storyboards: being able to view the whole layout on the screen at the same time. 但是,这太混乱了,我失去了Storyboard的好处:能够同时在屏幕上查看整个布局。

The other solution is to copy and paste the cell. 另一种解决方案是复制并粘贴单元格。 But now I have two copies of the same cell I'd need to manage. 但是现在我需要管理同一单元的两个副本。

Long shot, is there a way to dequeue a cell from a different UITableView? 远射,是否有办法从其他UITableView出队单元格?

I don't think you should do that. 我不认为你应该那样做。 I tried once to share a cell between my main table view and a search results table view, and it caused crashes. 我曾经尝试在主表视图和搜索结果表视图之间共享一个单元格,这导致崩溃。 I don't think having to copy and paste the cell a few times if you end up changing it is too much work if you really want to see everything in your storyboard. 我认为,如果最终要更改,则不必复制和粘贴单元格几次,如果您真的想在情节提要中看到所有内容,那将是一件繁重的工作。 If seeing the cell isn't that important (as opposed to seeing the controller hierarchy and flow), then I would go with the xib option. 如果查看单元格不是那么重要(与查看控制器层次结构和流程相反),那么我将使用xib选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM