1. 从文件中读取plist文件的路径
NSString *path = [[NSBundle mainBundle] pathForResource:@"more" ofType:@"plist"];
2. 初始化数据数组
_dataArray = [NSArray arrayWithContentsOfFile:path];
2) 通过tag直接获取UIImageView相关的属性
UILabel *titleLabel = (UILabel *)[cell viewWithTag:1002];
UILabel *ratingLabel = (UILabel *)[cell viewWithTag:1003];
4) 从数组中获取字典
NSDictionary *dic = _dataArray[indexPath.row];
5) 设置相应的内容
imageView.image = [UIImage imageNamed:dic[@"image"]];
titleLabel.text = dic[@"title"];
ratingLabel.text = dic[@"rating"];
return cell;
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"more" ofType:@"plist"];
2. 初始化数据数组
_dataArray = [NSArray arrayWithContentsOfFile:path];
1) 通过注册的方式,来创建单元格
// xib注册方式
[tableView registerNib:[UINib nibWithNibName:@"MoreCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"cell"];
// cell重用
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cell
forIndexPath:indexPath];2) 通过tag直接获取UIImageView相关的属性
UIImageView *imageView = (UIImageView *) [cell viewWithTag:1001];
3) 通过tag获取UILabelUILabel *titleLabel = (UILabel *)[cell viewWithTag:1002];
UILabel *ratingLabel = (UILabel *)[cell viewWithTag:1003];
4) 从数组中获取字典
NSDictionary *dic = _dataArray[indexPath.row];
5) 设置相应的内容
imageView.image = [UIImage imageNamed:dic[@"image"]];
titleLabel.text = dic[@"title"];
ratingLabel.text = dic[@"rating"];
return cell;
}