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