如果重新选择了选定的单元格,如何查看 [英] How to chack if selected cell got reselected

查看:61
本文介绍了如果重新选择了选定的单元格,如何查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的UITableViewCell,我扩展了选择范围。如果重新选择了所选的单元格,我想要做的是让单元格高度恢复正常(44)。这是我的代码:

I have a custom UITableViewCell, and I it expands on selection. What I want to do is make the cells height go back to normal (44), if the cell that was selected was reselected. Here is my code:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([indexPath isEqual:self.selectedCell] && ![[tableView indexPathForSelectedRow] isEqual:indexPath]) {
        return 100;
    }
    return 44;
}



代码工作正常,但它似乎忽略了if语句中的第二个术语。显然我做错了。有没有办法解决它?


The code works fine, but it seems to be ignoring the 2nd term in the if statement. Apparently I'm doing it wrong. Is there a way to fix it?

推荐答案

处理这样的东西。



Handle such stuff in the handler.

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath;





heightForRowAtIndexPath仅在加载过程中调用一次。



The heightForRowAtIndexPath is only called once in the load process.


这篇关于如果重新选择了选定的单元格,如何查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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