我有一个表视图和表视图4个部分。在第一节中,我只有一行,在这个房间里面增加了一个文本框。我为这个第一个单元分配一个自定义类。对于其他所有部分和行我分配第二类。但问题是当我在第一个单元格的文本字段中输入内容时。而我checkaccessorytype
检查其他细胞,我滚动表。然后文本框的文本完成,也细胞的附件改变了这是代码细胞附件变化也除去
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
if (section ==0)
{
return 1;
}
if (section ==1)
{
return [filterObj.priceName count];
}
if (section ==2)
{
return [filterObj.typeName count];
}
if (section ==3)
{
return [othersArray count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kCellID = @"DefaultCell";
static NSString *kCellTwoID = @"tblCell";
CustomCellWithTF *cell = (CustomCellWithTF *) [tableView dequeueReusableCellWithIdentifier:kCellID];
customCellTwo *cellTwo = (customCellTwo *) [tableView dequeueReusableCellWithIdentifier:kCellTwoID];
if(cell == nil)
{
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"custonCell" owner:self options:nil];
cell = (CustomCellWithTF *)[nibs objectAtIndex:0];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.accessoryType = UITableViewCellStyleDefault;
}
if(cellTwo == nil)
{
NSArray *nibsTwo = [[NSBundle mainBundle] loadNibNamed:@"customCellTwo" owner:self options:nil];
cellTwo = (customCellTwo *)[nibsTwo objectAtIndex:0];
cellTwo.selectionStyle = UITableViewCellSelectionStyleNone;
cellTwo.textLabel.font = [UIFont systemFontOfSize:12];
cellTwo.accessoryType = UITableViewCellStyleDefault;
}
if (indexPath.section == 0 && indexPath.row == 0)
{
cell.textLabel.text = @"Location";
location = [[UITextField alloc] initWithFrame:CGRectMake(130, 10, 150, 25)];
[location setBorderStyle:UITextBorderStyleRoundedRect];
location.delegate = (id)self;
[cell addSubview:location];
return cell;
}
if (indexPath.section == 1)
{
cellTwo.textLabel.text = [filterObj.priceName objectAtIndex:indexPath.row];
}
if (indexPath.section == 2)
{
cellTwo.textLabel.text = [filterObj.typeName objectAtIndex:indexPath.row];
}
if (indexPath.section == 3)
{
cellTwo.textLabel.text =[othersArray objectAtIndex:indexPath.row];
}
return cellTwo;
}
请你告诉我怎样才能解决这个问题
你根本没有回到细胞。你只能一直返回cellTwo。代码中有很多需要改变的地方。你能提供你想要达到什么样的截图吗?结果是什么? – 2013-04-26 11:22:31
我正在返回单元格,您可以看到 – zeshan 2013-04-26 11:23:26