我正在創建一個包含兩個部分的uitableview,部分== 0有5行,部分== 1有1行。如何定義uitableviewcells
我也已經在一個objective-c類中聲明瞭幾個函數,我想把它們分別插入到五行中。但我不知道如何實現這一點。
我想這是像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//---------- In here put a bunch of IF statments, declaring each cell? and linking it to
//---------- the function I have declared in the objective-c class
return cell;
}
嘗試使用'enum',它有助於可讀性。這樣,如果單元格是靜態的,你可以像'indexPath.row = MyTableViewRowFruit'或'indexPath.row = MyTableViewSectionResults' – Can