如何创建tableView单元格以便显示在tableView的顶部在方法cellForRowAtIndexPath
? 我想显示优先单元格在tableView单元格的顶部,检查它们是否有优先级,取决于havePriority
属性的bool
的值,例如,如果havePriority
为1,则应该是true,否则应该在优先级列表之后。 我尝试过使用不同的单元格标识符,但无法获得顶部的列表。确定表格视图单元格的优先级IOS
我的代码:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (havePriority) // if the cell wants priority to be at top, have a value in bool
{
cell.textLabel = sOmeText; //
NSLog(@"%@",sOmeText);
}
return cell;
优先考虑您的数据源,然后重新加载数据。 –