小编Fab*_*ghi的帖子

无法赋值:'word'是'let'常量

我得到以下错误:"无法赋值:'word'是'let'常数"我无法弄清楚为什么会发生这种情况.如果有人可以帮助我,我会非常感激.

这是代码:

import UIKit

class ViewController: UIViewController {

    var word1 = ""
    @IBOutlet weak var label: UILabel!

    func writeWord(word: String){
        word = "Example"
    }

    @IBAction func button(sender: AnyObject) {
        writeWord(word1)
        label.text = word1
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
Run Code Online (Sandbox Code Playgroud)

swift

9
推荐指数
2
解决办法
3万
查看次数

如何在Swift 2中使按钮框架自定义形状

我希望按钮只能在我创建的自定义多边形形状中进行反应,而不是在CGRect框架中.

button.frame只支持CGRect.

xcode frame uibutton cgrect swift

3
推荐指数
1
解决办法
2847
查看次数

标签 统计

swift ×2

cgrect ×1

frame ×1

uibutton ×1

xcode ×1