我已经提出了api请求,要求从我的后端服务中获取一些细节:
我想解雇我当前的视图控制器,并通过后端的网址启动新的网页:
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正在后台启动,但视图控制器不会被解雇。有什么建议吗?
答案 0 :(得分:2)
dismissViewControllerAnimated
:
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES completion:nil];
});
答案 1 :(得分:1)
尝试在主线程上运行dismiss代码:
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES completion:nil];
});