1
我有一個UITableView分組成部分,並在每個部分有一些行,所有的行都被禁用,所以他們只顯示信息,他們不允許用戶交互,除了非常最後一排。但是當用戶滾動瀏覽表格時,最後一行將被複制到表格中的其他行中。這是我的代碼。UITableview中的最後一行復制到其他行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.userInteractionEnabled = NO;
cell.accessoryType = UITableViewCellAccessoryNone;
UIFont *textLabelFont = [ UIFont fontWithName: @"Arial" size: 13.0 ];
UIFont *detailLabelFont = [UIFont fontWithName:@"Arial" size:13.0];
cell.textLabel.font = textLabelFont;
cell.detailTextLabel.font = detailLabelFont;
// Configure the cell.
[populatePolicyCells ProcessPolicyCell:cell IndexPath:indexPath];
if (indexPath.section == 3){
tableView.allowsSelection = YES;
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.userInteractionEnabled = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.textLabel.text = @"Manage Policy";
}
return cell;
}
任何人都可以幫忙嗎?
只是一個供參考,但我認爲一個問題也是你得到一個細胞用dequeueReusableCellWithIdentifier,然後在下一行創建一個新的無論如何。 –
謝謝,我將刪除它 – Popeye