WFCUBrowserViewController.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // BrowserViewController.m
  3. // WildFireChat
  4. //
  5. // Created by heavyrain.lee on 2018/5/15.
  6. // Copyright © 2018 WildFireChat. All rights reserved.
  7. //
  8. #import <WebKit/WebKit.h>
  9. #import "WFCUBrowserViewController.h"
  10. @interface WFCUBrowserViewController ()
  11. @property (nonatomic, strong)WKWebView *webView;
  12. @end
  13. @implementation WFCUBrowserViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
  18. [self.view addSubview:self.webView];
  19. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
  20. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"..." style:UIBarButtonItemStyleDone target:self action:@selector(onRightBtn:)];
  21. }
  22. - (void)onRightBtn:(id)sender {
  23. UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"浏览器打开" otherButtonTitles:nil, nil];
  24. [actionSheet showInView:self.view];
  25. }
  26. - (void)didReceiveMemoryWarning {
  27. [super didReceiveMemoryWarning];
  28. // Dispose of any resources that can be recreated.
  29. }
  30. /*
  31. #pragma mark - Navigation
  32. // In a storyboard-based application, you will often want to do a little preparation before navigation
  33. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  34. // Get the new view controller using [segue destinationViewController].
  35. // Pass the selected object to the new view controller.
  36. }
  37. */
  38. #pragma mark - UIActionSheetDelegate <NSObject>
  39. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
  40. if(buttonIndex == 0) {
  41. [[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString:self.url]];
  42. [self.navigationController popViewControllerAnimated:NO];
  43. }
  44. }
  45. @end