如何創建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;
優先考慮您的數據源,然後重新加載數據。 –