iphone - 如何使用 UIAlertView 关闭模态视图 Controller ?

标签 iphone objective-c ios xcode uialertview

我想通过在我实现的 UIAlertView 上点击取消来关闭整个模态视图 Controller 。警报 View 询问用户是否要注销,如果用户点击是,它将关闭模态视图 Controller 。

我如何在 Xcode 中执行此操作?

谢谢!

最佳答案

您可以先查看有关 uialertviewdelegate 的文档。

首先您需要将您的类声明为 uialertview 的委托(delegate),然后实现该方法以获取用户单击的按钮的索引。

您可以使用这些方法来检查用户的选择

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex

关于iphone - 如何使用 UIAlertView 关闭模态视图 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8354660/

相关文章:

ios - Flutter iOS 版本和配置文件构建无法正常工作

ios - 为什么编辑器里预览给错iphone型号

iphone - 用动画替换 window.rootViewController 部分有效

ios - 在 iOS 8 中将照片保存到自定义相册

iphone - 如何将NSMutableArray值转换为NSString?

iphone - NSFetchedResultsController,修改 NSFetchRequest?

iphone - 将消息发送到 objectForKey 到 NSMutableArray 实例,并且有效!!奇怪的?

iphone - 使用 iphone 上的 HTML5 视频元素,如何检测 "pause"和 "done"之间的差异?

php - 某些用户不再接收或发送 IOS 推送通知

iphone - 如何在 iOS 的 View 中保留导航工具栏