由于我是 IOS 开发的新手,我正在尝试添加CustomeCell
into tableView
但我无法从库中添加它。
我所做的只是拖动TableView
in my ViewController
并比拖动tableview
其中的单元格,但它添加为额外视图ViewController
的视图无法将其添加到表视图中。
我被困在这里,不知道如何通过拖放添加单元格。
截屏 :
我知道如何通过编码添加单元格,但通过代码添加所有内容的过程非常漫长。
任何指导将不胜感激。
Thanks in advance.
根据我的经验,您不能将自定义单元添加到TableView
当您使用或编辑您的视图控制器/视图/单元格 into XIB
.
为此,你有 2 个选择
1st:使用情节提要来设计您的TableViewCell
.
2nd:创建一个新的自定义单元格XIB
并将其加载到您的tableView
with NIB
名字如下。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCell"];
if (cell == nil) {
// Create a temporary UIViewController to instantiate the custom cell.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
}
希望这有助于将单元格添加到 XIB 中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)