简体   繁体   中英

How to hide top bar on QLPreviewController by default

I am presenting a QuickLook preview controller like so:

 QLPreviewController *qlController = [[QLPreviewController alloc] init];
    qlController.dataSource = self;
    qlController.delegate = self;
    dispatch_async(dispatch_get_main_queue(), ^{
        [rootVC presentViewController:qlController animated:NO completion:nil];
    });

I'm passing it a usdz preview item. As soon as the item loads in the top bar it disappears but the effect is jarring.

Is there any way to hide this top bar (highlighted in yellow) by default so it never shows up?

在此处输入图片说明

Yes you can, but after presenting QLPreviewController . Following code will works to hide navigation bar, but after few moment.

Objective-C:

[self presentViewController:qlController animated:true completion:^{
    UINavigationBar *navBar = [[[[[qlController view] subviews] firstObject] subviews] objectAtIndex:1];
    [navBar setHidden:true];
}];

Swift:

self.present(qlController, animated: true) {
    if let navigationBar = qlController.view.subviews.first?.subviews[1] as? UINavigationBar {
        navigationBar.isHidden = true
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM