zoukankan      html  css  js  c++  java
  • 进击的UI------------------- Plist&自定义Cell

    1.plist
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"name" ofType:@"plist"];
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
    2.tableView的自定义cell
    1⃣️:cell.m
    // 自定义cell的初始化方法
    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            [self p_setupView];
        }
        return self;
    }
    - (void)p_setupView{
        self.myImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 40, 40)];
    //    self.myImage.backgroundColor = [UIColor brownColor];
        // 自定义cell把控件添加到cell的contentView上面
        [self.contentView addSubview:_myImage];
        self.nameLable = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.myImage.frame) + 10, CGRectGetMinY(self.myImage.frame), CGRectGetWidth(self.contentView.frame) - CGRectGetWidth(self.myImage.frame) - 30,CGRectGetHeight(self.myImage.frame))];
        self.nameLable.backgroundColor = [UIColor brownColor];
        [self.contentView addSubview:_nameLable];
    }
    // 当bounds发生改变 走一个方法
    - (void)layoutSubviews{
        self.nameLable.frame = CGRectMake(CGRectGetMaxX(self.myImage.frame) + 10, CGRectGetMinY(self.myImage.frame), CGRectGetWidth(self.contentView.frame) - CGRectGetWidth(self.myImage.frame) - 30, CGRectGetHeight(self.myImage.frame));
    }
    2⃣️:controller.m
    - (void)viewDidLoad {
        [super viewDidLoad];
        // 1 先注册
        [self.tableView registerClass:[MyCell class] forCellReuseIdentifier:@"cell"];
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        // 用自定义cell
        MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
        cell.myImage.image = [UIImage imageNamed:@"1.png"];
        cell.nameLable.text = @"宋慧乔";
        cell.nameLable.font = [UIFont systemFontOfSize:20];
        return cell;
    }
    3.cell - model
    1⃣️:
    2⃣️:
    3⃣️:
    4⃣️:
    6⃣️:
     
  • 相关阅读:
    asp.net :使用jquery 的ajax +WebService+json 实现无刷新去后台值
    如何清理数据库缓存
    如何在虚拟机中Linux+Oracle10gRAC安装
    ORA01031 权限不足存储过程中DBA 角色用户无法执行DDL
    如何查看存储过程执行计划
    如何查看执行计划
    如何使用tkprof
    C#位运算讲解与示例[转]
    C#中Invalidate() 方法
    如何创建强命名程序集, 如何查看强命名程序集的PublicKeyToken
  • 原文地址:https://www.cnblogs.com/sharkHZ/p/4984108.html
Copyright © 2011-2022 走看看