如果特定单元格的属性匹配某些条件,则希望在表视图之间显示自定义视图。像这样
行1
行2
列(n)的(匹配条件)
---------------------------(自定义视图)
行第(n + 1)
行(n + 2)
我在ViewController中使用TableView和TableViewDelegate
您还需要带有委托的TableDataSource。刚返回的另一个单元格类,取决于表委托cellViewRateAtIndexPath:方法中源数组中对象的条件。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MyObjectClass * objectFromArray = [sourceArray.objectAtIndex: indexPath.row];
if(condition on MyObjectClass or index row){
static NSString *MyIdentifier = @"MyReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
}
return cell;
}
}else{
static NSString *MyOtherIdentifier = @"MyOtherReuseIdentifier";
NewUITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[NewUITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyOtherIdentifier];
}
return cell;
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句