我以这种方式设置UIAlertController:
此实现在viewDidLoad中完成-
actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
actionButton1 = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
actionButton2 = UIAlertAction(title: " Resend", style: .default) {
action in
self.resendCode()
}
actionButton2.setValue(UIImage(named: "MailForActionSheet"), forKey: "image")
actionButton2.setValue(0, forKey: "titleTextAlignment")
actionSheet.addAction(actionButton1)
actionSheet.addAction(actionButton2)
我将标题和消息设置为零,因为我不希望操作表中包含任何标题。 函数resendCode尝试以这种方式修改操作表(在同一viewcontroller中实现):
func resendCode()
{
actionButton2.isEnabled = false
actionSheet.title = "Resending Code not be done again"
actionSheet.message = ""
}
但是我所看到的只是空白的标题和消息(现在有标题)。这里有什么问题,我该如何纠正?
编辑: 单击按钮即可显示操作表 目前(actionSheet,动画:true,完成:nil)