最新上架一款新APP,一直构建失败。查询资料后才知道IOS13后新上架的APP不能在包含有UIWebView了。没办法,只能按规则修改了。
因为工程里使用了UIWebView来预览本地的pdf文件,按要求修改成QLPreviewController来加载显示(使用过WKWebView来加载,一直显示空白,暂时不知道什么原因)。
导入QuickLook.framework库
定位到TARGETS->Build Phases,在Link Binary With Libraries项添加QuickLook.framework。
代码实现
///头文件导入
#import <QuickLook/QuickLook.h>
///代理
@interface ReportVC ()<QLPreviewControllerDataSource,QLPreviewControllerDelegate>
@end
@implementation ReportVC
{
QLPreviewController *qlvc;
}
- (void)viewDidLoad
{
[super viewDidLoad];
qlvc = [[QLPreviewController alloc] init];
qlvc.dataSource = self;
qlvc.delegate = self;
[self presentViewController:qlvc animated:YES completion:nil];
}
///代理
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller{
return 1;
}
- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index{
NSURL *filePath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"pdf"]];
return filePath;
}
-(void)previewControllerDidDismiss:(QLPreviewController *)controller{
[self.navigationController popViewControllerAnimated:YES];
}
显示效果

注:如果你的工程里有用到AFNetworking,需升级到最新版本,可参考CocoaPods中升级AFNetworking
网友评论