简体   繁体   English

iphone:UIAlertView没有消失并阻止UIProgressView

[英]iphone: UIAlertView not disappearing and blocking UIProgressView

I have a UIAlertView that asks a user whether they want to copy a bunch of contacts. 我有一个UIAlertView,询问用户是否要复制一堆联系人。 After the user clicks "Continue," I want the AlertView to disappear to be replaced by a UIProgressView that shows the rate of loading. 在用户单击“继续”之后,我希望AlertView消失,由显示加载速率的UIProgressView替换。

Everything functions properly except that the alert remains on the XIB after the user clicks Continue, and it doesn't disappear until the entire process has run. 除了在用户单击“继续”后警报仍保留在XIB上时,一切都正常运行,并且在整个进程运行之前它不会消失。 As soon as it disappears, the UIProgressView bar appears but by then it has reached 100%. 一旦它消失,UIProgressView栏就会出现,但到那时它已达到100%。

How do I clear the UIAlertView off the screen immediately and show the progress bar growing instead. 如何立即从屏幕上清除UIAlertView并显示进度条的增长。

Here's the code. 这是代码。 Thanks for help. 感谢帮助。

-(IBAction)importAllAddressBook:(id)sender {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Import ALL Contacts" message:@"Do you want to import all your Address Book contacts?  (Please note that only those with a first and last name will be transfered)" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue", nil];
    [alert show];
    [alert release];


}

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

    if (buttonIndex == 0) {
        NSLog(@"NO STOP");
        return;
    }else {
        NSLog(@"YES CONTINUE");
        importAllContactsProgress.hidden = NO;  // show progress bar at 0
        [self importAllMethod];           
        }
}

// method to import all Address Book
-(void) importAllMethod {


    importAllContactsProgress.progress = 0.0;

   load names etc etc 

You'll want to perform the perform the import on a background thread: 您将要在后台线程上执行导入:

[self performSelectorInBackground:@selector(importAllMethod)];

Your import method is blocking the main thread and preventing any UI actions from occurring. 您的导入方法是阻止主线程并阻止任何UI操作发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM