Not able to add static UITableViewCell into tableview

倾然丶 夕夏残阳落幕 提交于 2019-12-04 10:21:46

As per my exprience you can not add Custom Cell into TableView while you are using or editing your ViewController/View/Cell into XIB.

For that you have 2 option

1st : Use Storyboard to design your TableViewCell.

2nd : Create new custom cell with XIB and load it into your tableView with NIB name like below.

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];
}

Hope this will help to add cell into XIB.

I'm sorry for late answer, if you're using xib layout check this;

Cannot add a PrototypeCell to UITableView inside xib file

Gurinder Batth

For this first select your TableView and in the Inspector Window Increase Prototype Cells by 1 as shown in ScreenShot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!