【发布时间】:2014-04-15 08:35:25
【问题描述】:
我有一个非常简单但很烦人的问题。我有两个视图控制器,在第一个中我有一个按钮,它必须去服务器并做一些工作,我想显示一个包含旋转指示器的警报视图,一旦按下按钮就会显示出来当第二个视图控制器加载时被解雇。
我试过这样:
- (IBAction)logMeInFunction:(id)sender {
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:@"Please Wait...." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[waitAlert show];
/* Do Some Api testing and stuff */
[waitAlert dismissWithClickedButtonIndex:0 animated:YES];
[self performSegueWithIdentifier: @"logMe" sender: self];
}
使用这种方式,警报显示会在第二个视图控制器中立即显示并关闭,而不是显示在第一个以通知用户某些工作正在完成并在第二个消失。 有什么想法吗?
【问题讨论】:
-
你能显示你的服务器调用吗?最好的选择是在调用完成时隐藏该警报视图,而不是在第二个视图控制器加载时隐藏。
-
你在后台做什么?我猜可能是异步任务。您应该等到登录任务(例如
NSURLConnection)完成后再切换视图。 -
这就是我得到 json 响应的方式: NSString *strURL2 = [NSString stringWithFormat:@"MyURL"]; NSData *dataURL2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL2]]; NSString *strResult2 = [[NSString alloc] initWithData:dataURL2 encoding:NSUTF8StringEncoding]; NSDictionary *json2 = [strResult2 JSONValue]; NSMutableArray *userExists = [[NSMutableArray alloc] init];我怎样才能完成你的建议?这是我的第一个 JSon 交互应用程序@chrisblomm
-
@Justafinger 请检查我上面的评论
标签: ios objective-c uibutton uialertview uiactivityindicatorview