AutoCell(自定义cell)

新建类@interface YadongCell : UITableViewCell方法

#pragma mark – 赋值方法

– (void)setCellDateWithYadong:(CinemaModel *)sender;

#pragma mark – 自定义高度

+(CGFloat)height;#pragma mark – 封装+ (instancetype)getYadongCellWithTtableView:(UITableView *)tableView;

方法实现

(nonatomic, strong) UILabel *nameLabel;@property (nonatomic, strong) UILabel *addrsLabel;@property (nonatomic, strong) UILabel *trafficLabel;@end- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];if (self) {[self createLabel];}return self;}#pragma mark – 创建 label- (void)createLabel{- 20, 30)];//[];- 20, 30)];[];- 20, 30)];[];}#pragma mark – 赋值方法- (void)setCellDateWithYadong:(CinemaModel *)sender{= sender.cinemaName;= sender.address;= sender.trafficRoutes;}#pragma mark – 自定义高度+(CGFloat)height;{return 120.0f;}#pragma mark – 封装+ (instancetype)getYadongCellWithTtableView:(UITableView *)tableView{static NSString *cellIdentifier = @”YadongCell”;YadongCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];cell;}// 给 tableView 注册,不用判断重用池是否为空(上面)[self.rootView.mainTableView registerClass:[YadongCell class] forCellReuseIdentifier:@”YadongCell”];// 有几种类型,就要注册几种:可以注册无数次[self.rootView.mainTableView registerClass:[YadongCell class] forCellReuseIdentifier:@”UITableViewCell”];实现cell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{YadongCell *cell = [YadongCell getYadongCellWithTtableView:tableView];// 设置cell的值[cell setCellDateWithYadong:self.dataArray[indexPath.row]];return cell;}

,而有的旅行是释放负面情绪,换个心情,轻装上阵。

AutoCell(自定义cell)

相关文章:

你感兴趣的文章:

标签云: