如何展开表格视图单元格?

Kishore库马尔

使用此代码扩展表格视图单元格,但对我而言不起作用。我知道此代码中存在一些错误,可帮助我查找。

![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\];
    }]

在此处输入图片说明 此图像是我的输出,当我单击与其他数据不合并的单元格时。

西尔瓦纳(Sylvanaar)

根据您要支持的iOS版本,答案可能有所不同,但似乎您没有实现 heightForRowAtIndexPath:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章