ios 7自定义UITableViewCell的内容视图 [英] ios 7 customizing UITableViewCell's content view

查看:102
本文介绍了ios 7自定义UITableViewCell的内容视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ios7 中使用故事板,在故事板编辑器中的表格视图单元格下显式查看内容视图(与以前从界面中隐藏的版本相反) 。

Using storyboard in ios7 the content view is explicitly viewed under the Table View Cell in the story board editor (opposed to previous versions where it was hidden from the interface).

问题是我无法再将单元格的自定义元素连接到我的自定义单元格的ib插座( UITableCellView 的子类)并且只能将它们连接到表的内容视图( UIView ),这些视图无法自定义(即其自定义类属性为灰色)

The problem is that I cannot connect the cell's custom elements to my custom cell's ib outlets anymore (subclass of UITableCellView) and can only connect them to the table's content view (UIView) which CANNOT be customized (i.e. its custom class attribute is grayed)

这让我可以选择使用我觉得不方便且不太优雅的标签。

This leaves me with the option to use tags which I find inconvenient and less elegant.

我还可以在xib中创建自定义视图,执行所有连接,然后手动将此自定义视图添加为表格的内容视图,但我正在寻找通过故事板编辑器进行操作。

I could also create a custom view in a xib, do all the connections and then manually add this custom view as the content view of the table but I am looking for a way doing it via the story board editor.

有没有办法在ios7的故事板编辑器中将UI元素连接到自定义单元格的内容视图?

Is there a way to connect UI elements to a custom cell's content view in the story board editor in ios7 ?

推荐答案

我能够通过以下方式做到这一点:

I was able to do this by doing the following:


  1. 选择文档大纲中的单元格

  2. 在Identity Inspector中更改其自定义类

  3. 将所需的任何元素放入内容视图

  4. 使用Connections Inspector将IBOutlets连接到内容视图中的元素

  1. Select the cell in the document outline
  2. Change its custom class in the Identity Inspector
  3. Place whatever elements you want into the content view
  4. Connect the IBOutlets to the elements inside the content view using the Connections Inspector

这篇关于ios 7自定义UITableViewCell的内容视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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