我创建了一个带有Menu-Structure的应用程序,并希望在初始化第一个ViewController之前有一个DownloadViewController。
因此我在DownloadViewController中编码:
NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:downloadUrl completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//Doing download stuff ... (still working)
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"firstViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:vc animated:YES completion:nil];
}];
[downloadTask resume];
呈现FirstViewController,所有功能仍然存在。但是UINavigationBar中的菜单图标在几秒钟后首先显示。有人可以帮帮我吗?
答案 0 :(得分:1)
这不是答案,只是提案
我写这里正确格式化评论,尝试改变:
NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:downloadUrl completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//Doing download stuff ... (still working)
dispatch_async(dispatch_get_main_queue()) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"firstViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:vc animated:YES completion:nil];
}
}];
[downloadTask resume];