使用此代码扩展表格视图单元格,但它不适用于我。我知道此代码中有一些问题可以帮助我查找。
![selectindex = -1;
// Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return \[Arr_lbl count\];
}
#pragma mark table cell creating and loading the data
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AntzclubCell *cell=\[tableView dequeueReusableCellWithIdentifier:@"Antz"\];
cell.img_antzClub.image=\[UIImage imageNamed:\[Arr_img objectAtIndex:indexPath.row\]\];
cell.lbl_antzClub.text=\[Arr_lbl objectAtIndex:indexPath.row\];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
cell.backgroundColor=\[UIColor blackColor\];
return cell;
}
#pragma mark expanding height
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectindex==indexPath.row){
return 400;
}
else{
return 132;
}
}
#pragma mark user selecting option
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row==selectindex) {
selectindex=-1;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:indexPath\] withRowAnimation:UITableViewRowAnimationFade\];
return;
}
if(selectindex !=-1)
{
NSIndexPath *prepath=\[NSIndexPath indexPathForRow:selectindex inSection:0\];
selectindex=indexPath.row;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:prepath\] withRowAnimation:UITableViewRowAnimationLeft\];
}
selectindex=indexPath.row;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:indexPath\] withRowAnimation:UITableViewRowAnimationFade\];
}]
这个图像是我输出的,当我点击它与未扩展的其他数据合并的单元格时。
答案 0 :(得分:0)
根据您要支持的iOS版本,答案可能会有所不同,但似乎您没有实现heightForRowAtIndexPath: