1.静态cell常用设置界面的,因为设置界面的的数据一般是死的,用静态cell比较方便搭建
2.现在实现在Storbord实现上面的cell是静态的cell,下面的cell是动态cell,实现两者混用的效果
1>创建一个静态cell在tableView
主要是在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//表示静态cell
if (indexPath.section == 0) {
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}else{
//表示动态cell
HTWarningViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HTWarningViewCell"];
return cell;
}
}
//表示cell中indexPath
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//表示动态cell在section 为 1 静态cell的section 0
if (section == 1) {
return self.selectedUserList.count;
}
return [super tableView:tableView numberOfRowsInSection:section];
}
//表示cell的内容缩进
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
//表示动态cell在section 为 1 静态cell的section 0
if (indexPath.section == 1) {
return 10;
}
return indexPath.row;
}