EXFriendController.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // EXFriendController.m
  3. // AIIM
  4. //
  5. // Created by gan on 2025/4/21.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "EXFriendController.h"
  9. #import "FriendNetApi.h"
  10. #import "EXFriendListCell.h"
  11. @interface EXFriendController()<UITableViewDelegate,UITableViewDataSource,EXFriendListCellDelegate>
  12. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  13. @property (nonatomic,strong) NSArray *friendlist;
  14. @end
  15. @implementation EXFriendController
  16. -(void)viewDidLoad{
  17. [super viewDidLoad];
  18. [self.navigationController setNavigationBarHidden:YES animated:NO];
  19. [_tableView registerClass:[EXFriendListCell class] forCellReuseIdentifier:@"friend"]; // 使用 Storyboard 时不需要这行代码,除非你混合使用 Storyboard 和代码配置 Cell。
  20. _tableView.delegate=self;
  21. _tableView.dataSource = self;
  22. _tableView.backgroundColor=[UIColor clearColor];
  23. [self getexfriends];
  24. }
  25. - (IBAction)gotoBack:(id)sender {
  26. NSLog(@"gotoBackgotoBackgotoBack");
  27. [self dismissViewControllerAnimated:YES completion:nil];
  28. }
  29. -(void)getexfriends{
  30. [FriendNetApi getvalidateList:nil succ:^(int code, NSDictionary * res) {
  31. NSLog(@"res:%@",res);
  32. self.friendlist = res[@"data"];
  33. if(self.friendlist){
  34. [self->_tableView reloadData];
  35. }
  36. } fail:^(NSError * _Nonnull error) {
  37. NSLog(@"error:%@",error);
  38. }];
  39. }
  40. -(void)actionNote:(NSString *)note{
  41. NSLog(@"note");
  42. [self getexfriends];
  43. }
  44. #pragma mark UITableViewDelegate
  45. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  46. return 1;
  47. }
  48. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  49. NSLog(@"numberOfRowsInSection:%lu",(unsigned long)self.friendlist.count);
  50. if(self.friendlist){
  51. return self.friendlist.count;
  52. }
  53. else{
  54. return 0;
  55. }
  56. }
  57. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  58. NSDictionary *data=self.friendlist[indexPath.row];
  59. NSLog(@"cellForRowAtIndexPath:%@",data);
  60. if(data){
  61. EXFriendListCell *cell =[tableView dequeueReusableCellWithIdentifier:@"friend" forIndexPath:indexPath];
  62. if(cell==nil){
  63. cell=[[EXFriendListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"friend"];
  64. }
  65. [cell fillWithData:data];
  66. cell.delegate = self;
  67. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  68. cell.backgroundColor = [UIColor clearColor];
  69. return cell;
  70. }
  71. return nil;
  72. }
  73. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  74. return 70;
  75. }
  76. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  77. NSLog(@"didSelectRowAtIndexPath:%@",indexPath);
  78. }
  79. @end