@IBDesignable错误:IB Designables:无法更新自动布局状态:Interface Builder Cocoa Touch Tool崩溃 [英] @IBDesignable error: IB Designables: Failed to update auto layout status: Interface Builder Cocoa Touch Tool crashed

查看:112
本文介绍了@IBDesignable错误:IB Designables:无法更新自动布局状态:Interface Builder Cocoa Touch Tool崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的UITextView子类,它添加了占位符功能,您可以在Text Field对象中找到它。这是我的子类代码:

I have a very simple subclass of UITextView that adds the "Placeholder" functionality that you can find native to the Text Field object. Here is my code for the subclass:

import UIKit
import Foundation

@IBDesignable class PlaceholderTextView: UITextView, UITextViewDelegate
{
    @IBInspectable var placeholder: String = "" {
        didSet {
            setPlaceholderText()
        }
    }
    private let placeholderColor: UIColor = UIColor.lightGrayColor()        
    private var textColorCache: UIColor!

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.delegate = self
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.delegate = self
    }

    func textViewDidBeginEditing(textView: UITextView) {
        if textView.text == placeholder {
            textView.text = ""
            textView.textColor = textColorCache
        }
    }

    func textViewDidEndEditing(textView: UITextView) {
        if textView.text == "" && placeholder != "" {
            setPlaceholderText()
        }
    }

    func setPlaceholderText() {
        if placeholder != "" {
            if textColorCache == nil { textColorCache = self.textColor }
            self.textColor = placeholderColor
            self.text = placeholder
        }
    }
}

在Identity Inspector中更改 UITextView 对象的类后到 PlaceholderTextView ,我可以在Attribute Inspector中设置 Placeholder 属性。代码在运行应用程序时效果很好,但不会在界面构建器中显示占位符文本。我还得到以下非阻塞错误(我假设这就是它在设计时不呈现的原因):

After changing the class for the UITextView object in the Identity Inspector to PlaceholderTextView, I can set the Placeholder property just fine in the Attribute Inspector. The code works great when running the app, but does not display the placeholder text in the interface builder. I also get the following non-blocking errors (I assume this is why it's not rendering at design time):


错误:IB Designables:无法更新自动布局状态:Interface Builder Cocoa Touch Tool崩溃

error: IB Designables: Failed to update auto layout status: Interface Builder Cocoa Touch Tool crashed

错误:IB Designables:无法呈现PlaceholderTextView的实例:渲染视图的时间超过200毫秒。您的绘图代码可能会遇到性能下降。

error: IB Designables: Failed to render instance of PlaceholderTextView: Rendering the view took longer than 200 ms. Your drawing code may suffer from slow performance.

我无法弄清楚导致这些错误的原因。第二个错误没有任何意义,因为我甚至没有覆盖drawRect()。任何想法?

I'm not able to figure out what is causing these errors. The second error doesn't make any sense, as I'm not even overriding drawRect(). Any ideas?

推荐答案

当Interface Builder Cocoa Touch Tool崩溃时会生成崩溃报告。论文位于〜/ Library / Logs / DiagnosticReports ,并命名为 IBDesignablesAgentCocoaTouch _ *。崩溃。在我的例子中,它们包含一个有用的堆栈跟踪,用于识别我的代码中的问题。

There are crash reports generated when Interface Builder Cocoa Touch Tool crashes. Theses are located in ~/Library/Logs/DiagnosticReports and named IBDesignablesAgentCocoaTouch_*.crash. In my case they contained a useful stack-trace that identified the issue in my code.

这篇关于@IBDesignable错误:IB Designables:无法更新自动布局状态:Interface Builder Cocoa Touch Tool崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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