// // JXNodeView.m // shiku_im // // Created by os on 2020/7/11. // Copyright © 2020 Reese. All rights reserved. // #import "JXNodeView.h" @interface JXNodeView() @property (nonatomic,weak) UITableView *tableView; @property (nonatomic,strong) NSMutableArray *dataArr; @end @implementation JXNodeView -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { _dataArr=[NSMutableArray arrayWithCapacity:0]; UIView *backView=[[UIView alloc]init]; backView.backgroundColor=[UIColor whiteColor]; [self addSubview:backView]; [backView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(JX_SCREEN_TOP+10); make.right.mas_equalTo(-44); make.width.mas_equalTo(100); make.height.mas_equalTo(160); }]; NSArray *urlArray=[[NSUserDefaults standardUserDefaults] objectForKey:@"www_Array"]; [_dataArr addObjectsFromArray:urlArray]; UITableView *tableView=[[UITableView alloc]init]; tableView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:1.0]; tableView.delegate=self; tableView.dataSource=self; [backView addSubview:tableView]; [tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.right.mas_equalTo(0); make.left.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; } return self; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *ID = @"JXnxxMyCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } NSDictionary *nodeDict=_dataArr[indexPath.row]; cell.textLabel.text=nodeDict[@"name"]; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 39; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSDictionary *nodeDict=_dataArr[indexPath.row]; if (_blockNode) { _blockNode(nodeDict); } } @end