在我的iOS应用程序中,我在每个ViewController中隐藏了带有此代码的状态栏:
- (BOOL)prefersStatusBarHidden
{
return YES;
}
在视图中我需要使用UIDocumentInteractionController,但是当它出现时,会出现状态栏,有没有办法让它隐藏?
提前致谢
答案 0 :(得分:2)
使用以下代码和iOS代码的组合:
- (UIViewController *) documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *) controller {
// hack to keep status bar visible
[[NSOperationQueue mainQueue] addOperationWithBlock:
^{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}];
return self;
}
结合
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
答案 1 :(得分:1)
试试这个对我有用:
- (void)documentInteractionControllerWillBeginPreview:(UIDocumentInteractionController *)controller
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
答案 2 :(得分:0)
将documentController.delegate
设为自己并使用
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}