故事板中的自定义 uitableviewcells [英] custom uitableviewcells in storyboard

查看:17
本文介绍了故事板中的自定义 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:

  1. 将单元格样式设置为自定义
  2. 将一些标签拖到原型单元格上.
  3. 向项目中添加一个新文件并使其成为 UITableViewCell 的子类
  4. 在我尝试自定义的单元格的身份检查器中,我将其类设置为我刚刚创建的新类.
  5. 尝试控制从单元格上的标签拖动到我刚刚创建的类的头文件以设置 IBOutlet,但它不会让我这样做.

我错过了什么?

推荐答案

将标签声明为自定义单元格类中的属性.在表格视图控制器中,allocdequeue 将单元格作为您的自定义类型,而不是作为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆