如何在弹出警报时启动activityindicator

时间:2010-12-13 06:41:37

标签: iphone objective-c xcode

在我的应用程序中,我需要显示导航到下一个屏幕的警报。每当用户点击确定按钮时,我需要启动一个uiactivity指示器并且警报必须消失。所以,当用户点击时我只能查看活动指示器在警告中确定。我可以实现这一点。这是我的代码:

             alert=[[UIAlertView alloc]initWithTitle:@"Deletion" message:@"You are done" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];

[alert release];


         -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
      {
         action:@selector(otherButtonTitles);

//index = alertDone.cancelButtonIndex;
       [alert dismissWithClickedButtonIndex:0 animated:YES];
         if(buttonIndex==0) {

    [self performSelectorInBackground:@selector (activityFunctionForDeletion) withObject:nil];


    //alert.hidden=YES;
    myResults *byDateScreen = [[myResults alloc]initWithNibName:@"myResults" bundle:nil];
    [self presentModalViewController:byDateScreen animated:YES];
    [byDateScreen dataDisplay];
    [byDateScreen release];
        [activity stopAnimating];
    [activity setHidden:YES];
    //[byDateScreen release];
    }
    }

1 个答案:

答案 0 :(得分:0)

对不起伙计们。我找到了解决问题的方法.. 我所做的不是写作        [alert dismissWithClickedButtonIndex:0 animated:YES];我在''activityFunctionForDeletion''方法中写了它。

所以当我点击确定时,警报消失,活动开始动画。