美文网首页iOS Developer
点击cell 改变当前cell高度

点击cell 改变当前cell高度

作者: 喵喵嘟噜啡 | 来源:发表于2017-04-21 16:06 被阅读399次

首先定义一个当前选择的标示

 NSIndexPath * _seleIndex;

初始化为

_seleIndex = nil;

-----------------------------    didSelectRowAtIndexPath 方法中

if (_seleIndex == indexPath) {

UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];

[cell setSelected:NO];

_seleIndex = nil;

}

else

{

_seleIndex = indexPath;

}

写个动画

[UIView animateWithDuration:0.1 animations:^{

[tableView beginUpdates];

[tableView endUpdates];

}];

-------------------------  heightForRowAtIndexPath  方法中

if (_seleIndex == nil) {

return 56;

}

else

{

if (_seleIndex == indexPath) {

return 120;

}else{

return 56;

}

}

相关文章

网友评论

    本文标题:点击cell 改变当前cell高度

    本文链接:https://www.haomeiwen.com/subject/nwylnttx.html