JXNodeView.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // JXNodeView.m
  3. // shiku_im
  4. //
  5. // Created by os on 2020/7/11.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXNodeView.h"
  9. @interface JXNodeView()<UITableViewDelegate,UITableViewDataSource>
  10. @property (nonatomic,weak) UITableView *tableView;
  11. @property (nonatomic,strong) NSMutableArray *dataArr;
  12. @end
  13. @implementation JXNodeView
  14. -(instancetype)initWithFrame:(CGRect)frame{
  15. if (self=[super initWithFrame:frame]) {
  16. _dataArr=[NSMutableArray arrayWithCapacity:0];
  17. UIView *backView=[[UIView alloc]init];
  18. backView.backgroundColor=[UIColor whiteColor];
  19. [self addSubview:backView];
  20. [backView mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.top.mas_equalTo(JX_SCREEN_TOP+10);
  22. make.right.mas_equalTo(-44);
  23. make.width.mas_equalTo(100);
  24. make.height.mas_equalTo(160);
  25. }];
  26. NSArray *urlArray=[[NSUserDefaults standardUserDefaults] objectForKey:@"www_Array"];
  27. [_dataArr addObjectsFromArray:urlArray];
  28. UITableView *tableView=[[UITableView alloc]init];
  29. tableView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:1.0];
  30. tableView.delegate=self;
  31. tableView.dataSource=self;
  32. [backView addSubview:tableView];
  33. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.top.mas_equalTo(0);
  35. make.right.mas_equalTo(0);
  36. make.left.mas_equalTo(0);
  37. make.bottom.mas_equalTo(0);
  38. }];
  39. }
  40. return self;
  41. }
  42. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  43. return _dataArr.count;
  44. }
  45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  46. static NSString *ID = @"JXnxxMyCell";
  47. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  48. if (!cell) {
  49. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  50. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  51. }
  52. NSDictionary *nodeDict=_dataArr[indexPath.row];
  53. cell.textLabel.text=nodeDict[@"name"];
  54. return cell;
  55. }
  56. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  57. return 39;
  58. }
  59. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  60. NSDictionary *nodeDict=_dataArr[indexPath.row];
  61. if (_blockNode) {
  62. _blockNode(nodeDict);
  63. }
  64. }
  65. @end