我正在创建一个简单的Navigationcontroller按钮以显示单击警报,但操作失败,请找到以下代码:
//Enable the buttons to edit
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Edit", style: .plain, target: self, action: #selector(EditEnable(sender:)))
@objc private func EditEnable(sender: UIBarButtonItem)
{
let alert = UIAlertController(title: "Time to change the Menu for Next Week",
message: "Message",
preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertAction.Style.default))
}
不确定我在做什么是错误的。请帮忙。
答案 0 :(得分:0)
您忘记显示警报了。
self.present(alert, animated: true, completion: nil)