我有一個顯示模態視圖的應用程序。在最後的模態視圖中,我有一個表單。一旦點擊完成按鈕,就會調用一個Web服務,它傳遞從用戶輸入的值。收到回覆後,模態視圖被解除。我希望顯示警報或操作表,要求用戶等待,因爲Web服務調用需要很長時間。問題在於警報或操作表只有在視圖被解除後纔會顯示。這是爲什麼發生?以下是完成功能的代碼:在模態視圖中顯示警報
-(void)reg:(id)sender {
if([password length] == 0) {
//show alert
}
//other validation
//This is were I write the alert
UIActivityIndicator *activity = [[UIActivityIndicator alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorStyleWhite];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Processing" delegate:self otherButtonTitles:nil];
[alert addSubview:activity];
[activity startAnimating];
[alert show];
WebServiceController *web = [[WebServiceController alloc]init];
//webservice called
//getting the response
//dismissing alert here
[self dismissModalViewControllerAnimated:YES];
}
您可以發佈警報代碼嗎? – visakh7 2011-03-08 11:37:12