0
如果我想在Objective-C中創建一個表格視圖,並且每個單元格的定製方式不同,我會創建多個原型單元格,對其進行自定義,並設置它們各自的標識符。然後,我會添加此代碼,以便單元格將顯示我如何定製它。顯示原型單元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
switch (indexPath.row)
{
case 0:
CellIdentifier = @"fj";
break;
case 1:
CellIdentifier = @"pg";
break;
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier forIndexPath: indexPath];
return cell;
}
現在我更新我的應用程序斯威夫特2,想知道如何編寫上面應該改變在斯威夫特工作2.感謝!
只是在Swift語法中。另外你可以添加Enum for Cell Identifiers。 – sunshinejr