ReleaseAtPeopleVC.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. //
  2. // ReleaseAtPeopleVC.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/11/28.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "ReleaseAtPeopleVC.h"
  9. #import "ReleaseAtPeopleCell.h"
  10. @interface ReleaseAtPeopleVC ()
  11. @property (nonatomic,strong) UITableView *tableView;
  12. @property (nonatomic,strong) NSMutableArray *dataArray;
  13. @property ( nonatomic,assign) int page;
  14. @property(nonatomic,strong) UIButton *closeBtn;
  15. @end
  16. @implementation ReleaseAtPeopleVC
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self initNavView];
  20. self.page = 1;
  21. self.dataArray = [NSMutableArray array];
  22. [self configureData];
  23. [self initUI];
  24. // Do any additional setup after loading the view.
  25. }
  26. - (void)initNavView{
  27. self.closeBtn = ({
  28. UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
  29. [btn setTitle:ASLocalizedString(@"取消")forState:UIControlStateNormal];
  30. [btn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
  31. btn.titleLabel.font = [UIFont systemFontOfSize:16];
  32. [btn addTarget:self action:@selector(closeButtonClick) forControlEvents:UIControlEventTouchUpInside];
  33. btn;
  34. });
  35. [self.view addSubview:self.closeBtn];
  36. [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.mas_equalTo(34);
  38. make.right.mas_equalTo(-10);
  39. }];
  40. UIButton * searchBtn = ({
  41. UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
  42. [btn setImage:[UIImage imageNamed:@"搜索"] forState:UIControlStateNormal];
  43. [btn addTarget:self action:@selector(searchBtnClick) forControlEvents:UIControlEventTouchUpInside];
  44. btn;
  45. });
  46. [self.view addSubview:searchBtn];
  47. [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.mas_equalTo(kTopHeight - 22);
  49. make.left.mas_equalTo(15);
  50. }];
  51. UILabel * titleLabel = [[UILabel alloc]init];
  52. titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
  53. titleLabel.font = [UIFont systemFontOfSize:16];
  54. titleLabel.text = ASLocalizedString(@"提醒谁看");
  55. [self.view addSubview:titleLabel];
  56. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.centerX.equalTo(self.view);
  58. make.centerY.equalTo(searchBtn);
  59. }];
  60. }
  61. - (void)closeButtonClick{
  62. [self.navigationController popViewControllerAnimated:YES];
  63. }
  64. - (void)searchBtnClick{
  65. }
  66. - (void)initUI{
  67. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, (kNavigationBarHeight+kStatusBarHeight), kScreenW, kScreenH - (kNavigationBarHeight+kStatusBarHeight)) style:UITableViewStylePlain];
  68. // if (isIPhoneX()) {
  69. // self.tableView.height = kScreenH - 49 - 64 - 20;
  70. // }
  71. NSLog(@"%f",kTabBarHeight);
  72. NSLog(@"%f",kNavigationBarHeight);
  73. self.tableView.delegate = self;
  74. self.tableView.dataSource = self;
  75. // self.tableView.backgroundColor = RGBCOLOR(244, 244, 244);
  76. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  77. [self.view addSubview:self.tableView];
  78. self.view.backgroundColor = kWhiteColor;
  79. // self.view.backgroundColor = RGBCOLOR(244, 244, 244);
  80. [self.tableView registerClass:[ReleaseAtPeopleCell class] forCellReuseIdentifier:NSStringFromClass([ReleaseAtPeopleCell class])];
  81. // [self.tableView registerClass:[CellForWorkGroupRepost class] forCellReuseIdentifier:NSStringFromClass([CellForWorkGroupRepost class])];
  82. [BGMJRefreshManager refresh:self.tableView target:self headerRereshAction:@selector(refreshHeader) footerRereshAction:@selector(refreshFooter)];
  83. }
  84. #pragma mark 下拉刷新
  85. - (void)refreshHeader
  86. {
  87. self.page = 1;
  88. [self loadDataWithPage:1];
  89. }
  90. #pragma mark 上拉加载
  91. - (void)refreshFooter
  92. {
  93. self.page ++;
  94. [self loadDataWithPage:self.page];
  95. }
  96. - (void)loadDataWithPage:(int)page
  97. {
  98. [BGMJRefreshManager endRefresh:self.tableView];
  99. }
  100. - (void)configureData{
  101. while (self.dataArray.count < 10) {
  102. PersonCenterUserModel * model = [[PersonCenterUserModel alloc]init];
  103. model.nick_name = [NSString stringWithFormat:ASLocalizedString(@"王%d明"),arc4random_uniform(30)];
  104. [self.dataArray addObject:model];
  105. }
  106. }
  107. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  108. return 1;
  109. }
  110. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  111. // return 5;
  112. return self.dataArray.count;
  113. }
  114. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  115. return 55;
  116. }
  117. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  118. ReleaseAtPeopleCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ReleaseAtPeopleCell class])];
  119. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  120. cell.user = self.dataArray[indexPath.row];
  121. return cell;
  122. }
  123. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  124. //block
  125. !self.releaseAtPeopleBlock?:self.releaseAtPeopleBlock(self.dataArray[indexPath.row]);
  126. [self.navigationController popViewControllerAnimated:YES];
  127. }
  128. @end