8.cell重用

来源:互联网 发布:tensorflow mnist 例子 编辑:程序博客网 时间:2024/06/05 20:53

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //定义静态标识符

    static NSString *cellIdentifier =@"cell";

    //检查表视图是否存在闲置的单元格

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier];

    }


    MovieModel *moviemodel = _subejectArray[indexPath.row];

//    cell.textLabel.text = [moviemodel.subject objectForKey:@"title"];//正确的写法

    cell.textLabel.text  = [moviemodel.subjectobjectForKey:@"title"];

    return cell;

}

0 0
原创粉丝点击