【问题标题】:How to dismiss alertview in delegate function - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex如何在委托函数中关闭警报视图 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
【发布时间】:2012-09-03 21:10:15
【问题描述】:

在我的应用程序中,当用户单击警报视图中的按钮时,我需要关闭警报视图。 我在我的应用程序中尝试了[alertView dismissWithClickedButtonIndex:-1 animated:NO];,但它不起作用。

【问题讨论】:

    标签: ios delegates uialertview dismiss


    【解决方案1】:

    什么都不做。

    在调用alertView:clickedButtonAtIndex: 委托方法后,警报视图会自动关闭。

    来自UIAlertViewDelegate Protocol Reference

    是什么让您认为您需要解除警报?您是否正在展示许多相同的 UIAlertView?

    【讨论】:

    • 单击按钮后,我需要进行一些数据分析,这可能需要一些时间,而我不希望用户在那里等待关闭警报视图。这就是我的意图。
    • 那么您需要停止在主线程上执行该工作,以便停止阻塞 UI。
    • 您有几个选项,包括 NSObject 的 -performSelectorInBackground: 或 GCD 操作或 dispatch_async 调用以在适当的队列上执行 NSOperation 或块。这里还有许多其他问题,Apple 提供了developer.apple.com/library/ios/#documentation/General/…。您应该使用哪一个取决于您需要完成的工作、如何将其并行化以及完成后需要如何传达结果。
    猜你喜欢
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多