MessageVC.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //
  2. // MessageVC.m
  3. // iphoneLive
  4. //
  5. // Created by YunBao on 2018/7/13.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MessageListVC.h"
  9. #import "MessageHeaderV.h"
  10. #import "MessageListCell.h"
  11. #import "MessageListModel.h"
  12. @interface MessageListVC ()<UITableViewDelegate,UITableViewDataSource>
  13. @property(nonatomic,assign)int paging;
  14. @property(nonatomic,strong)UITableView *tableView;
  15. @property(nonatomic,strong)MessageHeaderV *headerV;
  16. @property(nonatomic,strong)NSArray *models;
  17. @property(nonatomic,strong)NSMutableArray *dataArray;
  18. @end
  19. @implementation MessageListVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.navigationController.navigationBar.hidden = YES;
  23. self.dataArray = [NSMutableArray array];
  24. [self creatNavi];
  25. [self.view addSubview:self.tableView];
  26. }
  27. - (void)didReceiveMemoryWarning {
  28. [super didReceiveMemoryWarning];
  29. }
  30. #pragma mark - 数据更新
  31. - (NSArray *)models {
  32. if (!_models) {
  33. NSMutableArray *m_array = [NSMutableArray array];
  34. for (NSDictionary *dic in _dataArray) {
  35. MessageModel *model = [MessageModel modelWithDic:dic];
  36. [m_array addObject:model];
  37. }
  38. _models = m_array;
  39. }
  40. return _models;
  41. }
  42. -(void)pullData {
  43. }
  44. #pragma mark - 点击事件
  45. -(void)msgClickEvent:(NSString *)type {
  46. if ([type isEqual:@"粉丝"]) {
  47. NSLog(@"==粉丝==");
  48. }else if ([type isEqual:@"赞"]){
  49. NSLog(@"==赞==");
  50. }else if ([type isEqual:@"@我的"]){
  51. NSLog(@"==@我的==");
  52. }else{
  53. //评论
  54. NSLog(@"==评论==");
  55. }
  56. }
  57. #pragma mark - UITableViewDelegate、UITableViewDataSource
  58. //删除
  59. -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
  60. //[self.tableView reloadData];
  61. }
  62. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  63. if (section == 0) {
  64. return _window_width/4;
  65. }
  66. return 0.01;
  67. }
  68. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  69. if (section == 0) {
  70. _headerV = [[[NSBundle mainBundle]loadNibNamed:@"MessageHeaderV" owner:nil options:nil]objectAtIndex:0];
  71. _headerV.frame = CGRectMake(0, 0, _window_width, _window_width/4);
  72. _headerV.backgroundColor = Black_Cor;
  73. _headerV.headerBgV.backgroundColor = CellRow_Cor;
  74. _headerV.fansBtn = [PublicObj setUpImgDownText:_headerV.fansBtn space:15];
  75. _headerV.zanBtn = [PublicObj setUpImgDownText:_headerV.zanBtn space:15];
  76. _headerV.aiTeBtn = [PublicObj setUpImgDownText:_headerV.aiTeBtn space:15];
  77. _headerV.commentBtn = [PublicObj setUpImgDownText:_headerV.commentBtn space:15];
  78. WeakSelf;
  79. _headerV.msgEvent = ^(NSString *type) {
  80. [weakSelf msgClickEvent:type];
  81. };
  82. return _headerV;
  83. }
  84. return nil;
  85. }
  86. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  87. return 0.01;
  88. }
  89. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  90. return 80;
  91. }
  92. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  93. return self.models.count;
  94. }
  95. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  96. MessageCell *cell = [MessageCell cellWithTab:tableView andIndexPath:indexPath];
  97. cell.model = _models[indexPath.row];
  98. return cell;
  99. }
  100. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  101. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  102. }
  103. #pragma mark - set/get
  104. -(UITableView *)tableView {
  105. if (!_tableView) {
  106. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight-ShowDiff)style:UITableViewStylePlain];
  107. _tableView.delegate = self;
  108. _tableView.dataSource = self;
  109. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  110. _tableView.backgroundColor = Black_Cor;
  111. WeakSelf;
  112. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  113. weakSelf.paging = 1;
  114. [weakSelf pullData];
  115. }];
  116. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  117. weakSelf.paging +=1;
  118. [weakSelf pullData];
  119. }];
  120. }
  121. return _tableView;
  122. }
  123. #pragma mark - 导航
  124. -(void)creatNavi {
  125. YBNavi *navi = [[YBNavi alloc]init];
  126. navi.leftHidden = YES;
  127. navi.rightHidden = NO;
  128. navi.haveImgR = YES;
  129. [navi ybNaviLeft:^(id btnBack) {
  130. } andRightName:@"msg_linkman" andRight:^(id btnBack) {
  131. NSLog(@"选择联系人");
  132. } andMidTitle:@"关注"];
  133. [self.view addSubview:navi];
  134. }
  135. @end