我有一個UITableView部分。該部分中的所有單元格都具有從UITableViewCell的子類派生的名爲PLContactCell的單元。具有不同格式和行爲的UITableView單元格在同一表部分
我想要做的是,對於表格的最後一行,不使用PLContactCell。我只想使用我可以格式化的普通UITableViewCell,但是我想要。我也希望能夠讓這個單元格不響應被竊聽。
我最初的cellForRowAtIndexPath方法是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
PLContactCell *cell = [tableView dequeueReusableCellWithIdentifier:[PLContactCell reuseIdentifier]];
if (!cell) {
cell = [PLContactCell reusableCell];
cell.delegate = self;
}
id modelObject = [[sections objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
if ([modelObject isKindOfClass:[NSString class]]) {
[cell configureWithString:modelObject];
} else {
[cell configureWithUser:modelObject];
}
return cell;
}
EDIT 所以,我試圖創建的XIB文件一個UITableView細胞,並添加「newCell」的重用標識符給它。然後我添加了以下代碼:
if (indexPath.row == [[sections objectAtIndex:indexPath.section] count] - 1) {
NSString *CellIdentifier = @"newCell";
noFormatCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}
這什麼都不做。我的問題是,如何訪問該部分的最後一行,以及如何使它不是PLContactCell而是UITableView Cell。
您有具體問題嗎? –
也許在'cellForRowAtIndexPath:'你可以比較(indexPath.row + 1)到[tableView numberOfRowInSection:indexPath.section]的開頭,所以你知道你是否在最後一個單元格。如果是這樣,請致電另一個單元。但考慮Derek答案似乎是你需要的 – zbMax
@TimothyMoose:我的問題是,我如何訪問該部分的最後一行,以及如何使它不是一個PLContactCell,而是一個UITableView單元格。 – jac300