简体   繁体   English

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

[英]How to expand my table view cell?

Using this code to expand the table view cell,but its not working for me.I know there is some thing wrong in this code help me to find out. 使用此代码扩展表格视图单元格,但对我而言不起作用。我知道此代码中存在一些错误,可帮助我查找。

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

在此处输入图片说明 this image is my output while i click the cell its merged with other data not expanding. 此图像是我的输出,而我单击与其他数据不合并的单元格。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Swift中扩大表格视图单元格的高度? - How to expand the height of a Table View Cell in Swift? 如何设置单击以在 iOS 中的表格视图单元格上展开? - How to set a click to expand on a table view cell in iOS? 如何在目标c中通过增加单元格数来扩展表格视图? - How to expand table view with increasing cell number in objective c? 当在表视图中选择特定单元格时,如何使用另一个单元格扩展或替换单元格 - how to expand or replace the cell with another cell, when an particular cell select in table view 表视图单元格随文本大小扩展或收缩 - Table view cell expand or contract with the size of the text 将表格视图单元格扩展到内容的高度 - Expand table view cell to the content's height 单击同一单元格内的按钮时,如何折叠和展开表格视图单元格的某些部分? - How to Collpase and Expand some part of a table view cell when a button inside the same cell is clicked? 如何展开具有表格视图的自定义集合视图单元格? - How do I expand a custom collection view cell that has a table view on it? ios-像Twitter应用程序一样扩展表格视图单元格 - ios - Expand table view cell like Twitter app 如何将联系人姓名添加到表视图单元格? - How can I add the name of a contact to my table view cell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM