UINavigationItem在几秒钟后出现

时间:2016-08-13 12:12:15

标签: ios objective-c uinavigationbar

我创建了一个带有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中的菜单图标在几秒钟后首先显示。有人可以帮帮我吗?

屏幕截图:View出现后的NavigationBar: enter image description here 等待 20秒后enter image description here

1 个答案:

答案 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];