斯威夫特游乐场XCPShowView"无法满足约束" [英] Swift Playground XCPShowView "Unable to satisfy constraints"

查看:260
本文介绍了斯威夫特游乐场XCPShowView"无法满足约束"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让即时取景显示在斯威夫特游乐场一个简单的动画。每当我导入XCPlayground框架来执行 XCPShowView 的功能,我得到这个错误:

游乐场执行失败:错误:无法查找符号:_CGPointMake

对于其他一些符号的误差变化,以及包括 CGRectMake 。结果
被建议修改我code,除去从方法,如 CGRectMake 我还是得到X code。将错误,当我尝试动画制造之后我的看法。该错误消息是真的很长,但基本上它说:

无法同时满足约束条件。
    大概在以下列表中的约束条件中的至少一个是一个你不想要的。

下面是code我想一起工作:

 <$ C C> //圆圈键
类timerButtonGraphics:UIView的{
    覆盖FUNC的drawRect(RECT:的CGRect){
        让颜色绿色=的UIColor(红色:0.310,绿色环保:0.725,蓝:0.624,阿尔法:1.000)
        让colorRed =的UIColor(红色:二百五十五分之二百四十一,绿色环保:255分之93,蓝:二百五十五分之七十九,阿尔法:100)
        VAR边界= self.bounds
        VAR中心= CGPoint()
        center.x = bounds.origin.x + bounds.size.width / 2
        center.y = bounds.origin.y + bounds.size.height / 2
        VAR半径= 61
        VAR路径:UIBezierPath = UIBezierPath()
        path.addArcWithCenter(圆心,半径:CGFloat的(半径),由startAngle:CGFloat的(0.0),endAngle:CGFloat的(浮动(M_PI)* 2.0),顺时针方向:真)
        path.strokeWithBlendMode(kCGBlendModeNormal,阿尔法:100)
        path.lineWidth = 2
        如果strokeRed == {真
            colorRed.setStroke()
        }
        其他{
            colorGreen.setStroke()
        }
        path.stroke()
    }
    VAR strokeRed = TRUE
    }VAR测试= timerButtonGraphics(帧:的CGRect(X:0,Y:400,宽度:400,高度:400))UIView.animateWithDuration(2.0,延迟:2,usingSpringWithDamping:0.7,initialSpringVelocity:0.5,选项:无,动画:{
    test.transform = CGAffineTransformMakeTranslation(0.5,0)
    }完成:无)XCPShowView(圆动画,试)


解决方案

试试这个,也许它可以帮助你。

  test.setTranslatesAutoresizingMaskIntoConstraints(假)

I'm trying to get a Live View to show a simple animation in a Swift Playground. Whenever I import the XCPlayground framework to execute the XCPShowView function i get this error:

Playground execution failed: error: Couldn't lookup symbols:_CGPointMake

The error changes for a few other "symbols" as well, including CGRectMake.
After being advised to modifying my code to remove the "make" from methods such as CGRectMake I still get an error from Xcode when I try to animate my view. The error message is really long, but basically it says

"Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want."

Here is the code I am trying to work with:

//Circle Button
class timerButtonGraphics: UIView {
    override func drawRect(rect: CGRect) {
        let colorGreen = UIColor(red: 0.310, green: 0.725, blue: 0.624, alpha: 1.000)
        let colorRed = UIColor(red: 241/255, green: 93/255, blue: 79/255, alpha: 100)
        var bounds = self.bounds
        var center = CGPoint()
        center.x = bounds.origin.x + bounds.size.width / 2
        center.y = bounds.origin.y + bounds.size.height / 2
        var radius = 61
        var path:UIBezierPath = UIBezierPath()
        path.addArcWithCenter(center, radius: CGFloat(radius), startAngle: CGFloat(0.0), endAngle: CGFloat(Float(M_PI) * 2.0), clockwise: true)
        path.strokeWithBlendMode(kCGBlendModeNormal, alpha: 100)
        path.lineWidth = 2
        if strokeRed == true {
            colorRed.setStroke()
        }
        else {
            colorGreen.setStroke()
        }
        path.stroke()
    }
    var strokeRed = true
    }

var test = timerButtonGraphics(frame: CGRect(x: 0, y: 400, width: 400, height: 400))

UIView.animateWithDuration(2.0, delay: 2, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: nil, animations: {
    test.transform = CGAffineTransformMakeTranslation(0.5, 0)
    }, completion: nil)

XCPShowView("Circle Animation", test)

解决方案

try with this, maybe it can help you

test.setTranslatesAutoresizingMaskIntoConstraints(false)

这篇关于斯威夫特游乐场XCPShowView&QUOT;无法满足约束&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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