setStatusBarHidden stops working properly after UI

2019-08-05 06:37发布

问题:

So my app has the status bar set to be hidden like this in the AppDelegate. And it works as intended.

[[UIApplication sharedApplication] setStatusBarHidden:YES];

Then I use UIDocumentInteractionController's presentPreviewAnimated like this,etc.:

[self.docInteractionController presentPreviewAnimated:YES];

I observed that the status bar does show up (with battery info etc.) while in this UIDoc's preview mode. But after dismissing the preview and back to the original view, while the status bar is not there but there is a black bar instead. The size is same as the status bar.

Has anyone encountered this behavior and any remedy for this?

回答1:

I am facing the same issue. Found a quick fix to this issue...set the view's frame back inside viewWillAppear... My code looks something like this...

-(void)viewWillAppear:(BOOL)animated {  
  ... //other settings
  self.view.frame = [[UIApplication sharedApplication].keyWindow bounds];
}

Hope it helps! :)