在故事板中定制uitableviewcells [英] custom uitableviewcells in storyboard

查看:168
本文介绍了在故事板中定制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.

这是我在做什么:


  1. 将单元格样式设置为自定义


  2. 向项目添加一个新文件,并将其作为单元的身份检查器中的UITableViewCell

  3. 的子类

  4. TRY来控制从单元格上的标签拖动到我刚刚创建的类的头文件,以设置IBOutlet,但是它不会让我。

  1. set style of cell to custom
  2. dragging some labels onto the prototype cell.
  3. adding a new file to the project and making it a subclass of UITableViewCell
  4. in the identity inspector of the cell im trying to customize, I set its class to the new class I just created.
  5. TRY to control drag from the labels on the cell to the headerfile of the class I just created to setup an IBOutlet, but it won't let me.

我缺少什么?

推荐答案

将标签声明为自定义单元格类中的属性。在表视图控制器中, alloc dequeue 将单元格作为自定义类型,而不是 UITableViewCell 。在Xcode storyboard中,控制从单元格本身(例如,最右下角)到单元格中连接插座的标签。

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天全站免登陆