IBDesignable视图导致无休止的重建 [英] IBDesignable view causes endless rebuilding

查看:64
本文介绍了IBDesignable视图导致无休止的重建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写同时使用IBInspectable和IBDesignable的UIView子类.我没有做任何异常的事情,但是我的子类使Xcode 6.2不断重建项目.我的身份检查器在"Designables"标题下显示了这种状态振荡:

每次重新启动构建时,检查器都会失去焦点.这使得很难编辑IB中的任何内容,从而破坏了首先编写此类的目的.

这是我的DesignableTestView的实现:

import UIKit
@IBDesignable class DesignableTestView: UIView {

    @IBInspectable var testBackground:UIColor? {
        didSet {
            if testBackground != nil {
                self.backgroundColor = testBackground
            }
        }
    }
}

有什么方法可以更改我的代码或Xcode的设置,以防止不断重建?

解决方案

我想知道这个可设计的视图类是否是当前目标的一部分.在WWDC 2014视频 Interface Builder的新功能,实时视图演示,他们描述了第一步是确保可设计类位于单独的自定义框架目标中.该视频演示了在项目中创建此自定义框架目标的过程.

如果那不是问题.我建议清理您的项目(产品"菜单上的清理")并重新构建自定义框架目标,以确保在尝试在IB本身中执行任何操作之前可以.最重要的是,请确保可以毫无意外地构建框架.如果这样做之后问题仍然存在,我将其提升到一个新的水平,并且(a)找到Xcode派生的数据文件夹; (b)退出Xcode; (c)清除派生数据文件夹,(d)重新启动Xcode,并(e)尝试再次构建框架目标.


上面的链接似乎已死.可以直接从以下位置下载视频: http://devstreaming.apple.com/videos/wwdc/2014/411xx0xo98zzoor/411/411_hd_whats_new_in_interface_builder.mov?dl=1

还有一个github要点,其中包含所有2014年资料的链接: https://gist.github .com/jianpx/eea1e938d5868e980b11

I'm writing a UIView subclass that uses both IBInspectable and IBDesignable. I'm not doing anything unusual, but my subclass causes Xcode 6.2 to endlessly rebuild the project. My Identity Inspector shows this state oscillation under the heading 'Designables':

Every time the build restarts, the inspector loses focus. This makes it hard to edit anything from IB, which defeats the purpose of writing this class in the first place.

Here is the implementation of my DesignableTestView:

import UIKit
@IBDesignable class DesignableTestView: UIView {

    @IBInspectable var testBackground:UIColor? {
        didSet {
            if testBackground != nil {
                self.backgroundColor = testBackground
            }
        }
    }
}

Is there any way to change my code or settings of Xcode to prevent the constant rebuilding?

解决方案

I'm wonder if this designable view class is part of the current target. In WWDC 2014 video What's New in Interface Builder, in the Live Views demonstration, they describe that the first step is to ensure that the designable class is in a separate custom framework target. That video demonstrates the process for creating this custom framework target within the project.

If that's not issue. I'd suggest cleaning your project ("Clean" on "Product" menu) and rebuilding just the custom framework target to make sure that's ok before you try doing anything in IB, itself. Bottom line, make sure that the framework can be built without incident. If the problem still persists after doing that, I'd take it to the next level and (a) find the Xcode derived data folder; (b) quit Xcode; (c) clear the derived data folder, (d) restart Xcode, and (e) trying building the framework target again.

Edit:
Above link seems to be dead. Video can be downloaded directly from: http://devstreaming.apple.com/videos/wwdc/2014/411xx0xo98zzoor/411/411_hd_whats_new_in_interface_builder.mov?dl=1

There is also a github gist with links to all the 2014 material: https://gist.github.com/jianpx/eea1e938d5868e980b11

这篇关于IBDesignable视图导致无休止的重建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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