我有一个登录页面,当我按下“登录”按钮时,我必须调用 Web 服务并根据响应加载新视图,这需要 3 到 4 秒我想显示加载视图的活动指示器
如何证明
我正在使用带有 NSURLConnection 委托的异步 NSURLConnection
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
[conn start];
在didFinishLoading
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSError *e = nil;
res = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&e];
//[indicator performSelectorOnMainThread:@selector(stopAnimating) withObject:nil waitUntilDone:YES];
NSLog(@"data is %@",res);
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"create.json"];
NSLog(@"file path is %@ ",path);
NSFileManager *fileManager=[NSFileManager defaultManager];
if(![fileManager fileExistsAtPath:path])
{
NSString *bundle = [[[NSBundle mainBundle]resourcePath]stringByAppendingString:@"create.json"];
[fileManager copyItemAtPath:bundle toPath:path error:&error];
}
[res writeToFile:path atomically:YES];
如何在此视图中显示
我卡在这里