FileOpenViewController.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // FileOpenViewController.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/2/14.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "FileOpenViewController.h"
  9. @interface FileOpenViewController ()
  10. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  11. @property (strong, nonatomic) WKWebView *webView;
  12. @end
  13. @implementation FileOpenViewController
  14. + (FileOpenViewController *)initFileOpenViewController{
  15. FileOpenViewController *controller = [StoryboardManager.shared.myTDTopic instantiateViewControllerWithIdentifier:@"FileOpenViewController"];
  16. return controller;
  17. }
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.titleL.text = @"打开";
  21. self.webView = [[WKWebView alloc] init];
  22. [self.view addSubview:self.webView];
  23. [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.edges.mas_offset(UIEdgeInsetsZero);
  25. }];
  26. NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];//需要在线预览的文件
  27. NSURL *pathUrl = [NSURL URLWithString:path];
  28. //加载
  29. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  30. [self.webView loadRequest:request];
  31. }
  32. @end