Как я могу показать AlertView, когда приложение связывается с сервером через HTTP Post?Мой текущий код, который у меня есть, не работает правильно.
По сути, появляется AlertView с просьбой подтвердить что-то.Если подтверждено, имеет место следующий код:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{//this is for when the person clicks OK
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"OK"])
{
//do alert
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:@"Communicating with Server..."
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
loading.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[waitAlert addSubview:loading];
[loading startAnimating];
[waitAlert show];
//communicate with Server
RetailTransaction *retailTransaction = [[RetailTransaction alloc]init];
ServerConnection *serverConnection = [[ServerConnection alloc]init];
NSData *serverResponse = [serverConnection postData:[retailTransaction xmlToXml:
note.text:
pin.text:
total.text]];
NSString *serverResponseString = [[NSString alloc] initWithData:serverResponse
encoding:NSUTF8StringEncoding];
NSLog(@"Server Responded with: %@", serverResponseString);
В этом методе есть больше кода, но он дает основную информацию.waitAlert
даже не появляется до тех пор, пока приложение не свяжется с сервером, после чего оно появляется только на долю секунды.Кто-нибудь знает, почему это происходит?Это должно подойти до связи с сервером.Заранее спасибо.