随笔 - 0  文章 - 1  trackbacks - 0
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿

文章分类

文章档案

搜索

  •  

最新评论

闲话少说,上代码:

改变cell高度的代码:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
// If our cell is selected, return double height
    if([self cellIsSelected:indexPath]) {
        
return kCellHeight * 2.0;
    }
    
// Cell isn't selected so return single height
    return kCellHeight;
}

在点击cell时改变cell的高度,因此在didselect中添加关键语句:
[tableView beginUpdates];
[tableView endUpdates];

didselect中的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
// Deselect cell
    [tableView deselectRowAtIndexPath:indexPath animated:TRUE];
    
// Toggle 'selected' state
    BOOL isSelected = ![self cellIsSelected:indexPath];
    
// Store cell 'selected' state keyed on indexPath
    NSNumber *selectState = [NSNumber numberWithBool:isSelected];
    [selectedIndexes setObject:
selectState forKey:indexPath];
    
// This is where magic happens...
    [tableView beginUpdates];
    [tableView endUpdates];
}
大功告成!
posted on 2013-09-30 10:02 Long 阅读(901) 评论(0)  编辑 收藏 引用 所属分类: iOS

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理