重用同一情节提要中另一个表VC的单元格 [英] Reuse cell from another table VC in same storyboard

查看:60
本文介绍了重用同一情节提要中另一个表VC的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说在情节提要中我有两个表视图控制器(A和B).在A控制器中,我确实创建了带有标识符的单元原型:VIENS和DU.在B控制器中,我需要使用带有标识符DU的单元.我不想在B控制器中再次创建相同的外观单元格原型.这是在B控制器中重用A控制器的单元DU的一种方法吗?如果是,那该怎么办?

Lets say in storyboard I have two table view controllers (A and B). In the A controller I did create cell prototypes with identifiers: VIENS and DU. In the B controller I need to use cell with identifier DU. I do not want to create same look and feel cell prototype in the B controller once again. Is here a way to reuse cell DU from A controller in the B controller? If yes then how to do it?

推荐答案

做到这一点的最佳方法是根本不在情节提要中定义单元格.

The best way to do this is to not define the cell in the storyboard at all.

创建一个单独的NIB文件并在其中定义UITableViewCell.然后,您可以在表中注册笔尖并从那里加载它.现在,您只有一个单元格定义的副本,但是它可以在多个地方使用.

Create a separate NIB file and define the UITableViewCell in there. Then you can register the nib with the table and load it from there. Now you just have one copy of the definition of the cell but it can be used in multiple places.

在这里检查我的问题...

Check my question here...

UITableView registerNib:forCellReuseIdentifier:

这不是一个重复的问题,但是它将向您展示如何定义和注册笔尖.

It isn't a duplicate question but it will show you how to define and register the nib.

这篇关于重用同一情节提要中另一个表VC的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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