当我上下滚动tableview时,单元格中的内容会重叠,为什么是这样以及如何纠正它?当TableView滚动时,单元格内容重叠
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
IndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] ;
}
UITextField* tf = nil ;
switch (indexPath.row) {
case 0: {
cell.textLabel.text = @"First Name" ;
tf = firstNameTextField = [self makeTextField:self. placeholder:@"F name"];
[cell.contentView addSubview:firstNameTextField];
break ;
}
case 1: {
cell.textLabel.text = @"Last Name" ;
tf = lastNameTextField = [self makeTextField:self.lastName placeholder:@"L name"];
[cell.contentView addSubview:lastNameTextField];
break ;
}
case 2: {
cell.textLabel.text = @"age" ;
tf = agetextfield = [self makeTextField:self.password placeholder:@"Age"];
[cell.contentView addSubview:agetextfield];
break ;
}
}
return cell;
没有变化,我仍然得到相同的结果。 – Illep 2012-03-23 16:33:01
您是否尝试过cell.contentView = lastNameTextField – rakeshNS 2012-03-23 16:38:36
并将样式更改为UITableViewCellStyleDefault – rakeshNS 2012-03-23 16:39:59