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
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01