custom uitableviewcells in storyboard(故事板中的自定义 uitableviewcells)
问题描述
我想我已经完成了所有步骤,但我一定遗漏了一些东西,因为我无法将单元格中的标签与代码建立联系.
I think I got all the steps down but I must be missing something because I can't make a connection from the labels in the cell to the code.
这就是我正在做的事情:
Here's what I'm doing:
- 将单元格样式设置为自定义
- 将一些标签拖到原型单元格上.
- 向项目中添加一个新文件并使其成为 UITableViewCell 的子类
- 在我尝试自定义的单元格的身份检查器中,我将其类设置为我刚刚创建的新类.
- 尝试控制从单元格上的标签拖动到我刚刚创建的类的头文件以设置 IBOutlet,但它不会让我这样做.
我错过了什么?
推荐答案
将标签声明为自定义单元格类中的属性.在表格视图控制器中,alloc 或 dequeue 将单元格作为您的自定义类型,而不是作为 UITableViewCell.在 Xcode 故事板中,控制从单元格本身(例如,最右下角)拖动到单元格中的标签以连接插座.
Declare the label as a property in the custom cell class. In the table view controller, alloc or dequeue the cell as your custom type, not as UITableViewCell. In the Xcode storyboard, control drag from the cell itself (for example, the far bottom right corner) to the label that is in the cell to connect the outlet.
这篇关于故事板中的自定义 uitableviewcells的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:故事板中的自定义 uitableviewcells
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
