【发布时间】:2016-02-08 19:13:27
【问题描述】:
我有以下代码
let alertController = UIAlertController(title: "error_title".localized, message: "error".localized, preferredStyle: .ActionSheet)
let retryAction = UIAlertAction(
title: "retry".localized,
style: .Default,
handler: {
(action:UIAlertAction!) in
self.fetch()
}
)
alertController.addAction(retryAction)
let cancelAction = UIAlertAction(
title: "cancel".localized,
style: .Default,
handler: {
(action:UIAlertAction!) in
self.navigationController!.popViewControllerAnimated(true)
}
)
alertController.addAction(cancelAction)
self.presentViewController(alertController, animated: true, completion: nil)
对话框显示正常,但是当我单击按钮时,它不会调用处理函数。有什么想法吗?
【问题讨论】:
-
你是说点击按钮
retry? -
两个按钮都不起作用
-
将处理程序的主体替换为简单的 NSLogs 后,此代码对我有用。调用处理程序并隐藏操作表。您可以在处理程序中放置断点以确保它们不会被调用吗?当您按下这些按钮时,操作表会消失吗?也许问题出在其他地方。
-
您是否尝试过添加断点或记录以查看它是否至少到达那里?听起来可能很愚蠢,但这将是第一步。
标签: ios swift uialertcontroller