我有一个 alertController
,其中有一个 button
。以下是我创建按钮
的方法:
var myButton : UIAlertAction!
// Later...
self.myButton = UIAlertAction(title: "myButton", style: .Default, handler: {action -> Void in
self.myButton.title = "✔︎\(myButton)"
})
选择按钮后,我想在标题的开头添加一个“✔︎”。 (正如您在上面的最后一行代码中看到的。)当我尝试这样做时,出现以下错误:
Cannot assign to the result of this expression
我可以做什么来解决这个问题?如果 myButtons
标题是只读
,那么是否有有效的解决方法?
最佳答案
该错误与“✔︎”无关。这是因为 myButton
。将 UIAlertAction
分配给 String
没有任何意义。这就是您得到错误的方式。
关于ios - 更改按钮的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32341511/