QMChatRoomShowRichTextController.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // QMChatRoomShowRichTextController.m
  3. // IMSDK-OC
  4. //
  5. // Created by lishuijiao on 2018/3/8.
  6. // Copyright © 2018年 HCF. All rights reserved.
  7. //
  8. #import "QMChatRoomShowRichTextController.h"
  9. @interface QMChatRoomShowRichTextController ()<UIWebViewDelegate, UIScrollViewDelegate>{
  10. UIWebView *_webView;
  11. UIView *_topView;
  12. UIButton *_backButton;
  13. }
  14. @end
  15. @implementation QMChatRoomShowRichTextController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. [self createUI];
  20. [self createWebView];
  21. }
  22. - (void)createUI {
  23. _topView = [[UIView alloc] init];
  24. _topView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64);
  25. [self.view addSubview:_topView];
  26. _backButton = [[UIButton alloc] init];
  27. _backButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 60, 25, 40, 35);
  28. [_backButton setTitle:NSLocalizedString(@"button.back", nil) forState:UIControlStateNormal];
  29. [_backButton setTitleColor:[UIColor colorWithRed:13/255.0 green:139/255.0 blue:249/255.0 alpha:1] forState:UIControlStateNormal];
  30. [_backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
  31. [_topView addSubview:_backButton];
  32. }
  33. - (void)createWebView {
  34. _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 64)];
  35. _webView.scrollView.bounces = NO;
  36. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]];
  37. [_webView loadRequest:request];
  38. _webView.delegate = self;
  39. _webView.scrollView.delegate = self;
  40. _webView.scalesPageToFit = YES;
  41. [self.view addSubview:_webView];
  42. }
  43. - (void)backAction:(UIButton *)button {
  44. [self dismissViewControllerAnimated:true completion:nil];
  45. }
  46. - (void)didReceiveMemoryWarning {
  47. [super didReceiveMemoryWarning];
  48. // Dispose of any resources that can be recreated.
  49. }
  50. @end