我有一个简单的问题,关于表视图与3种不同种类的原型单元格.前两次只发生一次,而第三次发生4次.现在我很困惑的是如何在我的cellforRowatindexpath中指定哪个单元格原型用于哪一行.所以,我想要像第0行一样,使用原型1,第1行,使用原型2,行3,4,5和6使用原型3.最好的方法是什么?我给每个原型一个标识符,然后使用dequeueReusableCellWithIdentifier:CellIdentifier?
你能提供一些示例代码吗?
你能提供一些示例代码吗?
编辑:
还是行不通.这是我现在的代码. (我只有一个案例用于开关状态,因为我只想测试并看看单元格是否在第一行生成,但当前的表视图为空)
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- switch(indexPath.row)
- {
- case 0: {static NSString *CellIdentifier = @"ACell";
- UITableViewCell *cell = [tableView
- dequeueReusableCellWithIdentifier:@"ACell"];
- if(cell==nil) {
- cell=[[UITableViewCell alloc]
- initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"ACell"];
- }
- return cell;
- break;
- }
- }
- }
Acell是我创建的单元格原型的标识符.一世