BGBaseViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // BGBaseViewController.m
  3. // BugoLive
  4. //
  5. // Created by xfg on 16/11/25.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "BGBaseViewController.h"
  9. @interface BGBaseViewController ()
  10. @property (nonatomic, copy) BackBlock backBlock;
  11. @end
  12. @implementation BGBaseViewController
  13. - (void)dealloc
  14. {
  15. NSLog(@"dealloc %@", [self description]);
  16. [[NSNotificationCenter defaultCenter] removeObserver:self];
  17. [self hideMyHud];
  18. }
  19. - (void)didReceiveMemoryWarning
  20. {
  21. [super didReceiveMemoryWarning];
  22. }
  23. - (void)viewDidLoad
  24. {
  25. [super viewDidLoad];
  26. // 指定边缘要延伸的方向,子类有其他需求时记得重写该属性
  27. self.edgesForExtendedLayout = UIRectEdgeNone;
  28. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  29. // self.view.backgroundColor = kBackGroundColor;
  30. // 1、初始化变量
  31. [self initFWVariables];
  32. // 2、UI创建
  33. [self initFWUI];
  34. // LocalizationSetLanguage(@"zh-Hant");
  35. [self setUpLocalizationString];
  36. // 3、加载数据
  37. [self initFWData];
  38. }
  39. #pragma mark - ----------------------- 供子类重写 -----------------------
  40. #pragma mark 初始化变量
  41. - (void)initFWVariables
  42. {
  43. // 子类重写
  44. }
  45. #pragma mark UI创建
  46. - (void)initFWUI
  47. {
  48. // 子类重写
  49. }
  50. #pragma mark 加载数据
  51. - (void)initFWData
  52. {
  53. // 子类重写
  54. }
  55. #pragma mark - ----------------------- 返回按钮、事件 -----------------------
  56. - (void)setupBackBtnWithBlock:(BackBlock)backBlock
  57. {
  58. self.backBlock = backBlock;
  59. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(onReturnBtnPress) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  60. }
  61. #pragma mark - 返回上一级
  62. - (void)onReturnBtnPress
  63. {
  64. if (self.backBlock)
  65. {
  66. self.backBlock();
  67. }
  68. else
  69. {
  70. [self.navigationController popViewControllerAnimated:NO];
  71. }
  72. }
  73. #pragma mark - ----------------------- 指示器 -----------------------
  74. #pragma mark - HUD
  75. - (MBProgressHUD *)proHud
  76. {
  77. if (!_proHud)
  78. {
  79. _proHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  80. _proHud.mode = MBProgressHUDModeIndeterminate;
  81. }
  82. return _proHud;
  83. }
  84. - (void)hideMyHud
  85. {
  86. if (_proHud)
  87. {
  88. [_proHud hideAnimated:YES];
  89. _proHud = nil;
  90. }
  91. }
  92. - (void)showMyHud
  93. {
  94. [self.proHud showAnimated:YES];
  95. }
  96. #pragma mark - ----------------------- 无内容视图 -----------------------
  97. - (void)showNoContentView
  98. {
  99. [self.view addSubview:self.noContentView];
  100. }
  101. - (void)hideNoContentView
  102. {
  103. [self.noContentView removeFromSuperview];
  104. self.noContentView = nil;
  105. }
  106. - (BGNoContentView *)noContentView
  107. {
  108. if (!_noContentView)
  109. {
  110. // _noContentView = [BGNoContentView noContentWithFrame:CGRectMake(0, 0, 150, 175)];
  111. _noContentView = [[BGNoContentView alloc]initWithFrame:CGRectMake(0, 0, 150, 175)];
  112. _noContentView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
  113. }
  114. return _noContentView;
  115. }
  116. #pragma mark ------------------------ GET -----------------------
  117. - (NetHttpsManager *)httpsManager
  118. {
  119. if (!_httpsManager)
  120. {
  121. _httpsManager = [NetHttpsManager manager];
  122. }
  123. return _httpsManager;
  124. }
  125. - (GlobalVariables *)BuguLive
  126. {
  127. if (!_BuguLive)
  128. {
  129. _BuguLive = [GlobalVariables sharedInstance];
  130. }
  131. return _BuguLive;
  132. }
  133. @end