【发布时间】:2017-08-03 21:25:08
【问题描述】:
我正在开发一个需要查看/共享 PDF 文件的 React Native 应用程序。我正在使用react-native-open-file 模块,它使用 UIDocumentInteractionController 来查看 PDF 文件。打开 PDF 文件时,状态栏会出现在 PDF 上方。我的应用程序始终隐藏状态栏。如何在查看 PDF 时隐藏状态栏?
Here's the code from the module:
//
// RNDocumentInteractionController.m
// RNDocumentInteractionController
//
// Created by Aaron Greenwald on 7/5/16.
// Copyright © 2016 Wix.com. All rights reserved.
//
#import "RNDocumentInteractionController.h"
#import <UIKit/UIKit.h>
@implementation RNDocumentInteractionController
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(open: (NSURL *)path)
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:path];
interactionController.delegate = self;
[interactionController presentPreviewAnimated:YES];
}
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
return [[[[UIApplication sharedApplication] delegate] window] rootViewController];
}
@end
我能够添加一个 documentInteractionControllerDidEndPreview 方法,在它关闭后隐藏状态,但我宁愿永远不要打开状态栏:
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
更新:
这是菜单栏上方状态栏的图片:
【问题讨论】:
-
使用 setStatusBarHidden 永远隐藏状态栏?
-
@SunilPrajapati 是的,我根本不想看到状态栏。你问的是这个吗?
-
@SunilPrajapati 添加您链接到的更改后,是否需要对上述代码进行任何更改?
-
不,不需要对上述代码进行任何其他更改。对于整个应用程序隐藏状态栏
标签: ios objective-c react-native