![](/img/trans.png)
[英]Presenting a View Controller with a button in a UITableViewCell programmatically (Swift)
[英]Unable to change label text after presenting the view controller programmatically in swift
我使用以下代码在if else语句中以编程方式呈现视图:
if (Condition)
{
.....
}
else
{
var vc = self.storyboard?.instantiateViewControllerWithIdentifier("gameover") as UIViewController
self.presentViewController(vc, animated: true, completion: nil)
finalMsg.text="Thank you"
}
因此,视图正在更改,但是我无法更改标签finalMsg的文本,该文本属于我以编程方式更改的视图(游戏结束)。
我收到错误消息“严重错误:解开可选值时意外发现nil”
有人可以帮我吗?
设置“ vc”的“ finalMsg”:
vc.finalMsg.text =“谢谢”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.