0
我想在那一刻我UIAlert我上面的UIActivityIndicatorView看,我有這樣的代碼:認沽UIAlertView中上述UIActivityIndicatorView
- (void)showWithLabelDeterminate{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.delegate = self;
HUD.labelText = @"Loading";
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}
- (void)myProgressTask
{
float progress = 0.0f;
while (progress < 0.99f)
{
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
if(progress > 0.02f & progress < 0.05f)
{
NSString * string = [NSString stringWithFormat:@"http://localhost:8080/......"];
NSURL *url = [NSURL URLWithString:string];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(!urlData)
{
[self simpleAlert];
}
else
{
datos = [[NSMutableString alloc]initWithData:urlData encoding:NSISOLatin1StringEncoding];
}
}
}
}
-(void)simpleAlert
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Dont connect!!" delegate:self cancelButtonTitle:@"Refresh" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
的問題是,我沒有看到我上面的UIActivityIndicatorView我的UIAlertView中.....
我想完成我的UIActivityIndicatorView,因爲在這一刻它不會是必要的。 – Davidin073
在發佈的代碼中沒有UIActivityIndicatorView,推測它是內置於MBProgressHUD的?如果我不得不猜測,我會這樣說,在我的兩個猜測中,可能你想改變你對simpleAlert的調用,以便在主線程上發佈它。 – Tommy
是的,是的,對不起湯米,我提到MBProgressHUD,是的,我想關閉這個progressHUD並初始化我的UIAlertView。 – Davidin073