是否可以将IBDesignable与UICollectionViewCells一起使用,并在情节提要中对其进行实时渲染? [英] Is it possible to use IBDesignable with UICollectionViewCells and live render them in storyboard?

查看:104
本文介绍了是否可以将IBDesignable与UICollectionViewCells一起使用,并在情节提要中对其进行实时渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何将@IBDesignable与自定义视图一起使用. 但是可以将IBDesignable用于单元格并在情节提要中渲染它们吗?

I know how to use @IBDesignable with custom views. but is it possible to use IBDesignable for cells and render them in storyboard?

例如:我在情节提要中有一个collectionViewController,并添加了一个uiCollectionCell和指定的类作为我的customCellClass.

for example: i have a collectionViewController in storyboard, and added a uiCollectionCell and specified class as my customCellClass.

p.s:我知道要在collecionViews和tableViews中使用Xib,我们必须在代码中调用方法registerNib:forReuseIdentifer(而且我正在这样做).只是想知道,是否有可能在情节提要中看到它的渲染视图.

p.s: i know for using Xibs in collecionViews and tableViews we have to call method registerNib:forReuseIdentifer in code (and i am doing it). just wondered, is it possible to see it's rendered view in storyboard or not.

p.s2:我发现,它与UIViews完美结合,但是不知道如何使它与CollectionCells和TableCells一起使用. :(

p.s2: i found this and it works perfectly with UIViews, but don't know how to make it work with CollectionCells and TableCells. :(

推荐答案

经过大量测试并使用了库之后,我想到了:

After lots of testing and working with the library I came up with this:

您不应在.nib文件内添加TableViewCellCollectionViewCells,而是必须添加简单的视图.我不确定它是否会显示在情节提要中(尚未检查),但是它会使错误消失.现在,您甚至可以使用autoLayout来调整单元格的大小.

you should not add TableViewCell or CollectionViewCells inside .nib files, instead you have to add simple View. I'm not sure if it's gonna show up inside storyboard or not (haven't checked it yet) but it makes errors go away. Now you can even use autoLayout for self sizing cells.

这篇关于是否可以将IBDesignable与UICollectionViewCells一起使用,并在情节提要中对其进行实时渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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