I set the View controller-based status bar appearance to NO on info,plist. I also set application.statusBarHidden = true but status bar reappears automatically when the QLPreviewControl is presented. I don't want statusbar on my application. How could it be hidden?
2 Answers
QLPreviewController works for you from the separate system process via XPC. That's why everything you trying to change on it could be not actually changed on the real instance.
Also it manages status bar in its own way depending on full-screen mode (e.g. when you open PDF file and make tap on the navigation bar).
However, you can subclass it and try to override your properties in your own controller.
Try to set/override in subclass following properties:
modalPresentationCapturesStatusBarAppearance = true
prefersStatusBarHidden = true
setNeedsStatusBarAppearanceUpdate()
Could be that you will have to restore status bar hidden state after user tapped on navigation bar to hide and then tapped again to show it.
I had the same problem and found a similar solution. In Objective-C, these steps worked for me:
- Subclass
QLPreviewController
. In the .h file, add@import QuickLook;
. In the .m file, add this method:
- (BOOL)prefersStatusBarHidden { return YES; }
In the info.plist, if the Boolean property “View controller-based status bar appearance” is present, set its value to YES.
In your AppDelegate class, add this line to
didFinishLaunchingWithOptions
:[UIApplication sharedApplication].statusBarHidden = YES;
If your info.plist file already has "Status bar is initially hidden” set to YES, step 4 may not needed.