作者:吕小布 | 来源:互联网 | 2023-01-20 19:01
PrevioustoiOS8weusedtheUIActionSheetforshowingalertandnowweneedtousetheUIAlertContr
Previous to iOS8 we used the UIActionSheet for showing alert and now we need to use the UIAlertController.
在iOS8之前,我们使用UIActionSheet来显示警报,现在我们需要使用UIAlertController。
When we used the UIActionSheet we could easily handle situations where the user clicked outside the pop up (which means he want to cancel the operation) by comparing the clickedButtonAtIndex to the cancelButtonIndex - if the user indeed pressed outside the popup we got the cancel button index in this function.
当我们使用UIActionSheet时,通过将clickedButtonAtIndex与cancelButtonIndex进行比较,我们可以轻松处理用户在弹出窗口外点击的情况(这意味着他想要取消操作) - 如果用户确实在弹出窗口外按下了取消按钮索引在这个功能。
How can we handle these situations with the new UIAlertController? I tried to use the "completion" block but it doesn't have any context. Is there an easy way to handle this? (other than "saving" the actions states in some general variable).
我们如何使用新的UIAlertController处理这些情况?我试图使用“完成”块,但它没有任何上下文。有一个简单的方法来处理这个? (除了“保存”某些一般变量中的动作状态)。
3 个解决方案