0

嗨,伙计们,我有一个名为的方法manageui,它会显示一段时间的等待视图,当超时时,它UIAlertView会显示一条消息以重试我的问题是我无法隐藏UIAlertView调用之前的manageui调用

这是我的代码:

    -(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 的代表是:

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

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

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

2 回答 2

1

尝试这个:

[alertView dismissWithClickedButtonIndex:0 animated:YES];

于 2013-03-13T08:57:08.610 回答
0

好吧,我认为您不了解代表的概念

文档中它说alertView:clickedButtonAtIndex:

调用此方法后,接收器会自动关闭。

是的,不需要单独声明来关闭警报视图。只要按下按钮alertviewalertview消失,就会调用该方法

于 2012-10-17T13:25:10.260 回答