IBDesignable和UITableViewCell [英] IBDesignable and UITableViewCell

查看:125
本文介绍了IBDesignable和UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在XCode 6中利用Swift的IBDesignable功能来创建UITableViewCell的子类

I'm trying to leverage IBDesignable features of Swift in XCode 6 to create a subclass of UITableViewCell

我在WWDC演示和网络上看到 - 你可以使用一个框架来创建一个视图的子类(UIView),然后可以用在一个自定义的UITableViewCell中,这不是我想要的。

I see in the WWDC demo, and on the web - that you can use a framework to create a subclass of a view (UIView) which can then be used in say, a custom UITableViewCell, which is not really what I want.

我可以直接用UITableViewCell做同样的事情吗?如果我在我的框架中公开UITableViewCell,然后尝试在Interface Builder中使用它,我在设计时无法访问我的自定义视图组件。

Can I do the same thing with a UITableViewCell directly? If I expose a UITableViewCell in my framework, then try to use it in Interface Builder, I don't have access to my custom view components at design time.

更糟糕的是 - 我甚至无法通过在StoryBoard上创建的Outlets在运行时显示我的自定义视图。

What's worse - I can't even get my custom view to show at run time via Outlets created on the StoryBoard.

提前感谢任何指针...

Thanks in advance for any pointers...

推荐答案

我的理解是 IBDesignable 旨在与嵌入在xib中其他视图中的 UIView 的子类一起使用。尝试创建一个可检查/可设计的自定义 UIView 子类,并将其添加为单元格的 contentView 的第一个子视图xib,并从那里进行所有自定义。

My understanding is that IBDesignable is intended to be used with subclasses of UIView that are embedded inside other views in your xib. Try creating a custom UIView subclass that is inspectable/designable, and add it as the cell’s contentView’s first subview in the xib, and do all your customization from there.

这篇关于IBDesignable和UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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