Ios 打印不使用UIDocumentInteractionController?
我正在使用UIDocumentInteractionController查看PDF。当我打开PDF时,单击右上角箭头指向上方的正方形,然后选择“打印无任何结果”。你知道怎么解决这个问题吗 这是我的密码:Ios 打印不使用UIDocumentInteractionController?,ios,objective-c,react-native,Ios,Objective C,React Native,我正在使用UIDocumentInteractionController查看PDF。当我打开PDF时,单击右上角箭头指向上方的正方形,然后选择“打印无任何结果”。你知道怎么解决这个问题吗 这是我的密码: UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:path]; interactionController.
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:path];
interactionController.delegate = self;
dispatch_sync(dispatch_get_main_queue(), ^{
[interactionController presentPreviewAnimated:YES];
});
更新:
我忘了提到,我还有下面的代码,因为没有它,状态栏会显示在文档预览菜单栏上。我不得不添加下面的代码,因为我的应用程序总是隐藏状态栏,当文档预览打开时,状态栏会覆盖菜单栏。如果我删除代码,打印功能可以正常工作
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
[[[[UIApplication sharedApplication] delegate] window] setWindowLevel:UIWindowLevelStatusBar];
return [[[[UIApplication sharedApplication] delegate] window] rootViewController];
}
在.h文件中添加此行:
@property (strong, nonatomic) UIDocumentInteractionController *documentInteractionController;
并将这些文件保存到.m文件中:
self.documentInteractionController= [UIDocumentInteractionController interactionControllerWithURL:url];
//set delegate
[self.documentInteractionController setDelegate:self];
//provide button's frame from where popover will be lauched
[self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
参考:
我尝试了该代码,但没有解决问题,但我发现了更多细节。我添加了更多的代码和更新。谢谢你的帮助!