zoukankan      html  css  js  c++  java
  • plist文件的读取和xib加载cell

    plist 文件读取

    例如在工程里倒入了plist文件

    在工程里需要用到plist文件里的信息,就需要把plist文件读取出来。

    如程序:

    -(NSArray *)moreDataArr{
        if (!_moreDataArr) {
            NSString *plistPath = [[NSBundle mainBundle]pathForResource:@"MoreData.plist" ofType:nil];
            _moreDataArr = [NSArray arrayWithContentsOfFile:plistPath];
        }
        return _moreDataArr;
    }
    

    读取plist文件分两步走:

    • 获取plist文件在资源里的路径

    • 倒入获得数组类型的数据

    xib加载cell

    加载xib分三步走:

    注册cell:

    [self.tableView registerNib:[UINib nibWithNibName:@"GuessLoveCell" bundle:nil] forCellReuseIdentifier:@"guessLoveCell"];
    

    调用tableView代理方法

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        GuessLoveCell *cell = [tableView dequeueReusableCellWithIdentifier:@"guessLoveCell" forIndexPath:indexPath];
        cell.model = self.guessLoveModelArr[indexPath.row];
        return cell;
    }
    

    在GuessLoveCell类里调用model的setter方法来赋值

    -(void)setModel:(GuessLoveModel *)model{
        _model = model;
        //相关值
    }
  • 相关阅读:
    Centos 系统常用编译环境
    Centos 8 阿里yum源配置
    Centos 7 端口聚合
    mount ,mkfs 工具详细说明
    linux sed命令介绍
    Curl获取相关数据
    linux磁盘读写性能监控
    单机转RAC,添加新节点
    AIX环境Java进程cpu瓶颈分析(转)
    linux系统安全之pam的介绍
  • 原文地址:https://www.cnblogs.com/YaoJinye/p/5856919.html
Copyright © 2011-2022 走看看