【发布时间】:2017-06-11 19:30:52
【问题描述】:
我已发出 api 请求以从我的后端服务获取一些详细信息:
我想关闭我当前的视图控制器并通过从后端传入的 url 启动一个新网页:
NSDictionary *parameters = @{@"X-Service-Code" : @"PP", @"Accept" : @"application/json", @"Content-Type" : @"application/json"};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:url1 parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSMutableArray *jsonArray = [[NSMutableArray alloc]init];
jsonArray = [NSJSONSerialization JSONObjectWithData: responseObject options:NSJSONReadingMutableContainers error:nil];
[self dismissViewControllerAnimated:YES completion:nil];
NSString *urlAddress = [[jsonArray objectAtIndex:10]valueForKey:@"value"];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlAddress]]];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
webview 正在后台启动,但是视图控制器没有被关闭。有什么建议吗?
【问题讨论】:
-
即使您已经关闭了 self,您仍在显示 self.webView?我有点迷路了。我不认为这是
"because its not performed on the main thread thing"的问题,因为如果您不设置完成队列,它将始终在主队列完成,除非您指定afnetwork 的completionQueue 以使用不同的队列。
标签: ios objective-c iphone xcode webview