表格视图单元格可展开iOS [英] Table view cell expandable iOS

查看:84
本文介绍了表格视图单元格可展开iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个只有cels的表格视图,当您点击一个单元格时,它应该展开并显示更多的点击的单元格的信息。

I want a table view with only cels, and when you click on a cell it should expand and show more info of the clicked cell.

相当一些话题,但是他们中的大多数都链接到苹果开发者页面上的表视图动画和手势。这是以不同的方式。

I've seen quite some topics on this, but the most of them are linking to Table View Animations and Gestures on the apple developer page. Which does it in a different way. They use header sections, but I want to use the cell which is expandable for layout reasons.

我已经尝试过几种方法,主要是使用

I already tried several things mainly with

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {    

    if (isSearching && indexPath.row == selectedIndex) {
        return 110;
    }
    else {
        return rowHeight;       
    }

当我点击单元格时,单元格被展开,细胞保持相同。扩展后的单元格高度应与详细信息中的文本量相关。

When I Click on the cell, the cell is expanded but the info in that cell stays the same. Also the heigth of the cell when expanded should be related to the amount of text in the details.

Thnx!

推荐答案

您可以通过使用自定义单元格来实现。创建两个自定义单元格,一个用于普通行,另一个用于扩展行。当用户触摸特定单元格时,您可以记录它的indexPath并重新加载tableView。在重新加载时,您可以使用刚刚发布的代码更改此选定行的高度(仅增加所选单元格的高度)。这将产生扩展单元格的效果。

You can achieve this through the use of custom cells. Create two custom cells, one for the normal row and other for the expanded row. When the user touches a particular cell, you can record it's indexPath and reload the tableView. While reloading you can change the height of this selected row using the code that you've just posted(increasing the height of only the selected cell). This would give an effect of expanding cell.

这篇关于表格视图单元格可展开iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆