ios - IBDesignable 永远不会完成 Storyboard中 UITableViewCell 的更新

标签 ios xcode swift storyboard ibdesignable

这是与 this 类似的问题但不完全相同。

我创建了一个 UITableViewCell 的子类,它引用了一个自定义 Nib 并将其标记为@IBDesignable。在代码和 .xib 文件中所做的更改在模拟器和设备上正确显示,但在 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
    }
}

Storyboard显示一个永久的“Designables Updating”。

Designables Updating

将问题分解为一个不太复杂的测试,即仅对 UITableViewCell 进行子类化并将其标记为 @IBDesignable 会导致相同的永久“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 中。

最佳答案

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

我已将此问题报告给 Apple,并且至少知道这是一个已知错误。它目前是问题 ID 17973876 下的未解决问题。

编辑:截至 2016 年 12 月 7 日,此错误仍标记为未解决。

关于ios - IBDesignable 永远不会完成 Storyboard中 UITableViewCell 的更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32216670/

相关文章:

ios - UICollectionViewCell 背景颜色更改适用于 cellForItemAtIndexPath 但不适用于 didSelectItemAtIndexPath

ios - App Store Connect 和 TestFlight 中缺少应用商店图标

ios - Firebase 的 snapshot.value 转换为 Bool 突然返回 nil

ios - Swift 注释 "Tag"

c# - MonoTouch 无法获取现有钥匙串(keychain)项目的值(value)

ios - Cocos2D 自动化旋转 90 度

xcode - SWIFT + 解析 signUpInBackgroundWithBlock 不再有效 : Xcode 6. 3.1

ios - 如何在另一个方法中调用具有多个输入参数的方法

swift - SpriteKit 在我离开游戏后保留内存

ios - 将 UIScrollView 偏移从 Swift 4 中的另一个 viewController 更改为顶部