BGBaseTableViewController.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // BGBaseTableViewController.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/7/5.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGBaseTableViewController.h"
  9. @interface BGBaseTableViewController ()
  10. @property (nonatomic, copy) BackBlock backBlock;
  11. @end
  12. @implementation BGBaseTableViewController
  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. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  27. // 1、初始化变量
  28. [self initFWVariables];
  29. // 2、UI创建
  30. [self initFWUI];
  31. // 3、加载数据
  32. [self initFWData];
  33. }
  34. - (NetHttpsManager *)httpsManager
  35. {
  36. if (!_httpsManager)
  37. {
  38. _httpsManager = [NetHttpsManager manager];
  39. }
  40. return _httpsManager;
  41. }
  42. - (GlobalVariables *)BuguLive
  43. {
  44. if (!_BuguLive)
  45. {
  46. _BuguLive = [GlobalVariables sharedInstance];
  47. }
  48. return _BuguLive;
  49. }
  50. - (NSMutableArray *)mainDataMArray
  51. {
  52. if (!_mainDataMArray)
  53. {
  54. _mainDataMArray = [NSMutableArray array];
  55. }
  56. return _mainDataMArray;
  57. }
  58. - (void)setupBackBtnWithBlock:(BackBlock)backBlock
  59. {
  60. self.backBlock = backBlock;
  61. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(onReturnBtnPress) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  62. }
  63. #pragma mark - 返回上一级
  64. - (void)onReturnBtnPress
  65. {
  66. if (self.backBlock)
  67. {
  68. self.backBlock();
  69. }
  70. else
  71. {
  72. [self.navigationController popViewControllerAnimated:YES];
  73. }
  74. }
  75. #pragma mark - 供子类重写
  76. #pragma mark 初始化变量
  77. - (void)initFWVariables
  78. {
  79. }
  80. #pragma mark UI创建
  81. - (void)initFWUI
  82. {
  83. }
  84. #pragma mark 加载数据
  85. - (void)initFWData
  86. {
  87. }
  88. #pragma mark - HUD
  89. - (MBProgressHUD *)proHud
  90. {
  91. if (!_proHud)
  92. {
  93. _proHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  94. _proHud.mode = MBProgressHUDModeIndeterminate;
  95. }
  96. return _proHud;
  97. }
  98. - (void)hideMyHud
  99. {
  100. if (_proHud)
  101. {
  102. [_proHud hideAnimated:YES];
  103. _proHud = nil;
  104. }
  105. }
  106. - (void)showMyHud
  107. {
  108. [self.proHud showAnimated:YES];
  109. }
  110. #pragma mark - Table view data source
  111. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  112. {
  113. return 0;
  114. }
  115. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  116. {
  117. return 0;
  118. }
  119. /*
  120. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  121. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
  122. // Configure the cell...
  123. return cell;
  124. }
  125. */
  126. /*
  127. // Override to support conditional editing of the table view.
  128. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  129. // Return NO if you do not want the specified item to be editable.
  130. return YES;
  131. }
  132. */
  133. /*
  134. // Override to support editing the table view.
  135. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  136. if (editingStyle == UITableViewCellEditingStyleDelete) {
  137. // Delete the row from the data source
  138. [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  139. } else if (editingStyle == UITableViewCellEditingStyleInsert) {
  140. // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  141. }
  142. }
  143. */
  144. /*
  145. // Override to support rearranging the table view.
  146. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
  147. }
  148. */
  149. /*
  150. // Override to support conditional rearranging of the table view.
  151. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
  152. // Return NO if you do not want the item to be re-orderable.
  153. return YES;
  154. }
  155. */
  156. /*
  157. #pragma mark - Navigation
  158. // In a storyboard-based application, you will often want to do a little preparation before navigation
  159. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  160. // Get the new view controller using [segue destinationViewController].
  161. // Pass the selected object to the new view controller.
  162. }
  163. */
  164. @end