objective-c - 当uialertview进入其委托(delegate)方法时如何隐藏它?

标签 objective-c ios xcode ios5 ios6

大家好,我有一个名为 manageui 的方法,它会显示等待 View 一段时间,当超时时,它会显示 UIAlertView ,它会显示一条重试消息 我的问题是,在调用 manageui 之前,我无法隐藏 UIAlertView

这是我的代码:

    -(void)mangeui
{
    double Currenttime=0;
    double ptime=Currenttime+5000;
     NSLog(@"fire /n");

    do 
    {
        //add condition for found session
        if (Currenttime<ptime)
        {
            NSLog(@"inside if");
            [spinner setHidden:NO];
            [alert setHidden:YES];
        }
        else
        {

            alert = [[UIAlertView alloc] initWithTitle:@"Oops:(" 
                                                            message:@"No device found \n Make sure bluetooth is activated and the devices are within range." 
                                                           delegate:self 
                                                  cancelButtonTitle:@"Tap to retry"
                                                  otherButtonTitles:nil];

         [spinner setHidden:YES];
            [alert show];

        }

        Currenttime+=1;
    } while (Currenttime < ptime+1 &&[_matchmakingClient availableServerCount]==0);
}

alertview 的委托(delegate)是:

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

{
    [alertView dismissWithClickedButtonIndex:1 animated:true];
    [spinner setHidden:NO];

    alertView.hidden=YES;
    [self mangeui];
}

最佳答案

试试这个:

[alertView解雇WithClickedButtonIndex:0动画:是];

关于objective-c - 当uialertview进入其委托(delegate)方法时如何隐藏它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12934970/

相关文章:

objective-c - 在 Objective-C 方法中重新指向指针

c++ - libzip 外部库包含在 xcode 项目中

objective-c - Cocoa - 在运行时确定类的属性

ios - 收到推送通知

iphone - 隔离版本升级安装和首次安装

ios - 如何翻转图像并使其在所有状态下正确显示

ios - iOS 8 中单个 UITableViewCell 上有 2 个多行标签

iphone - iOS - 计算距离、方位角、仰角和相对位置(增强现实)

ios - UIButton 颜色自行改变

ios - 如何下载 Cocoalumberjack?