简体   繁体   English

iOS开发-如何显示使用自定义Table View Controller在Interface Builder中创建的静态单元格?

[英]iOS development - How to display static cells created in Interface Builder with custom Table View Controller?

I was trying to display something in static cells with a Table View. 我试图用表格视图在静态单元格中显示某些内容。

First I create a Table View Controller in interface builder with static cells. 首先,我在带有静态单元格的接口构建器中创建一个Table View Controller。

I never designate a custom UITableViewController class, it works well. 我从不指定自定义UITableViewController类,它可以很好地工作。

But since I designate it to MyTableViewController class, the table view displays nothing. 但是由于我将其指定为MyTableViewController类,因此表视图什么也不显示。

How to make static cells appear when using a custom UITableViewController class? 使用自定义UITableViewController类时如何使静态单元格出现?

In the method: 在方法中:

cellForRowAtIndexPath

you have to get a cell with identifier and then manage it and return it: 您必须获取一个带有标识符的单元格,然后对其进行管理并返回:

static NSString *identifier = @"YourCellIdentifier";

CustomCell *cell = [tableView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

return cell;

you must set identifier in interface builder..you have to select the cell and write the identifier in the inspector field. 您必须在接口构建器中设置标识符。.您必须选择单元格并将标识符写入检查器字段。

暂无
暂无

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

相关问题 如何在Xcode Interface Builder中向表视图控制器(带有静态单元格)添加导航项? - How do I add a navigation item to a Table View Controller (with static cells) in Xcode Interface Builder? 如何显示在界面生成器中定义的自定义单元格? - How to display custom cells that have been defined in interface builder? Interface Builder:无法将自定义类分配给表视图控制器 - Interface Builder : cannot assign custom class to table view controller 如果我们希望在同一表视图控制器ios中使用静态单元格以及动态单元格,那么如何在ios中实现呢? - If we want static cell as well dynamic cells in same table view controller ios, how it can be possible in ios? 带有静态单元格的表视图控制器 - Table view controller with static cells 如何在Swift / iOS中将静态表格视图控制器单元约束到安全区域 - How to constrain static table view controller cells to Safe Area in Swift/iOS 用Xib创建的自定义视图在Interface Builder中不起作用 - Custom view created with Xib not working in Interface Builder 在Interface Builder中创建的Table View Controller在iPhone X上的底部单元格被剪切和遮盖 - Table View Controllers created in Interface Builder have their bottom cells clipped and obscured on iPhone X iOS8使用Interface Builder自行调整静态TableView单元格 - iOS8 self-sizing static TableView cells with Interface Builder 如何为使用xib用户界面创建的TableViewController设置静态表视图 - how to set a static table view for a TableViewController that is created with xib user interface
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM