translatesAutoresizingMaskIntroConstraints无法分配

时间:2015-11-05 10:09:38

标签: swift autolayout

当我编写代码时:(快速代码)

我写这篇文章试图解决布局问题,我的标签一直停留在左下角。

label.translatesAutoresizingMaskIntoConstraints = false

我收到此错误:

"Cannot assign to the result of this expression"

我的功能(Nextlevel是我无法分配自动调整语句的标签):

@IBAction func check(sender: AnyObject) {


    var strValue = boxShots.text
    var floatValue = Double((strValue as NSString).integerValue)
    var strValue2 = boxMakes.text
    var floatValue2 = Double((strValue2 as NSString).integerValue)
    var stage = "stage 2"
    var procent = floatValue2 / floatValue * 100
    if floatValue < 99
    {
        stageText.text = "text text";
    }

    else if floatValue > 99 && floatValue2 > 49 && procent > 49.99
    {

        stageText.text = "test text"

    } else {
        stageText.text = "test text"

    }
    if floatValue > 99 && floatValue2 > 49 && procent > 49.99
    {
        nextLevel.translatesAutoresizingMaskIntoConstraints = false
        nextLevel.center = CGPointMake(160, 284)
        nextLevel.textAlignment = NSTextAlignment.Center
        nextLevel.userInteractionEnabled = true
        nextLevel.text = "Go to next stage"
        self.view.addSubview(nextLevel)

        let gestureRecognizer = UITapGestureRecognizer(target: self, action: "handleTap:")
        nextLevel.addGestureRecognizer(gestureRecognizer)

    }

func handleTap(gestureRecognizer: UIGestureRecognizer) {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc: AnyObject! = storyboard.instantiateViewControllerWithIdentifier("stagethree")
    self.presentViewController(vc as UIViewController, animated: true, completion: nil)
}


}

0 个答案:

没有答案