这适用于没有Interface Builder.
class LargeImageCell:normalimageCell {…}
tableVIEw.registerClass(normalimageCell.self,forCellWithReuseIDentifIEr: normalimageCell.ID())tableVIEw.registerClass(LargeImageCell.self,forCellWithReuseIDentifIEr: LargeImageCell.ID())
这与Interface Builder崩溃:
tableVIEw.registerNib(normalimageCell.nib(),forCellWithReuseIDentifIEr: normalimageCell.ID())tableVIEw.registerNib(LargeImageCell.nib(),forCellWithReuseIDentifIEr: LargeImageCell.ID())
顺便说一下,我正在声明像这样的nib和ID方法:
class normalimageCell: UItableVIEwCell { class func ID() -> String { return String(self) } class func nib() -> UINib { return UINib(nibname: String(self),bundle: nil) }}class LargeImageCell: normalmageCell { ...}解决方法 你应该从主包中检索nib,如:
class func nib() -> UINib { return UINib(nibname: String(self),bundle: NSBundle.mainBundle())}总结
以上是内存溢出为你收集整理的Swift – 如何从绑定到xib文件的自定义单元格继承全部内容,希望文章能够帮你解决Swift – 如何从绑定到xib文件的自定义单元格继承所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)