简体   繁体   中英

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.

My current solution is to have a separate nib for the cell and load the bundle in cellForRowAtIndexPath: for both view controllers. 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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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