gpt4 book ai didi

ios - 使用 UIDocumentInteractionController 时隐藏状态栏?

转载 作者:技术小花猫 更新时间:2023-10-29 10:38:02 51 4
gpt4 key购买 nike

我正在开发一个需要查看/共享 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];
}

更新:

这是菜单栏上方的状态栏图片:

Here's a picture of the status bar over the menu bar

最佳答案

我认为下面的代码应该可以:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
[[[[UIApplication sharedApplication] delegate] window] setWindowLevel:UIWindowLevelStatusBar];

return [[[[UIApplication sharedApplication] delegate] window] rootViewController];
}

关于ios - 使用 UIDocumentInteractionController 时隐藏状态栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42770804/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com