IBDesignable永远不会在情节提要中完成UITableViewCell的更新 [英] IBDesignable never finishes updating UITableViewCell in storyboard

查看:114
本文介绍了IBDesignable永远不会在情节提要中完成UITableViewCell的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与类似,但不完全相同.

This is a similar question to this but not quite the same.

我创建了UITableViewCell的子类,该子类引用了自定义笔尖并将其标记为@IBDesignable.在代码中以及从.xib文件进行的更改都可以在模拟器和设备上正确显示,但在情节提要中不能正确显示.

I have created a subclass of UITableViewCell which references a custom nib and marked it as @IBDesignable. Changes that are made both in code and from the .xib file display correctly in the simulator and on a device but not in the storyboard.

import UIKit

@IBDesignable class TextFieldTableViewCell: UITableViewCell {

    var view: UIView!

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        setup()
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)

        setup()
    }

    func setup() {
        view = loadViewFromNib()
        view.frame = bounds
        view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
        contentView.addSubview(view)
    }

    func loadViewFromNib() -> UIView {

        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: "TextFieldTableView", bundle: bundle)
        let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView

        return view
    }
}

情节提要显示永久的"Designables更新".

The storyboard displays a permanent "Designables Updating".

将问题简化为一个不太复杂的测试,只需将UITableViewCell子类化并将其标记为@IBDesignable即可在相同的永久"Designables更新"中进行结果.

Breaking the problem down into a less complex test of only subclassing a UITableViewCell and marking it as @IBDesignable results in the same permanent "Designables Updating".

import UIKit

@IBDesignable class TextFieldTableViewCell: UITableViewCell {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }

}

有人成功创建了@IBDesignable UITableViewCell子类吗?这是在Xcode 7 beta 6和beta 5中发生的.

Has anyone had success with creating a @IBDesignable UITableViewCell subclass? This is happening in Xcode 7 beta 6 and beta 5.

推荐答案

此问题已从Xcode 9开始解决.

我已向苹果公司报告了此问题,至少我一心知道这是一个已知的错误.当前是一个尚未解决的问题,问题编号为17973876.

I had reported this issue to Apple and at least have the piece of mind knowing that this is a known bug. It is currently an open issue under the problem ID 17973876.

截至2016年12月7日,此错误仍标记为未解决.

As of 12/7/2016 this bug is still marked as open.

这篇关于IBDesignable永远不会在情节提要中完成UITableViewCell的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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