2010-05-04 87 views
1

我知道可以设置UITable中所有行的高度,但是可以将一行设置为大于其他行。 例如,当用户用两根手指触摸单元格时,我希望单元格展开并显示说明。但只有那个细胞。这可能没有重叠在它下面的单元格?一个表格查看单元格/行比其他更大?

回答

1

使用的UITableViewDelegate方法heightForRowAtIndexPath

告诉别人,你的数据模型存储在具有height属性的对象:

- (void) changeHeightForRowAtIndexPath: (NSIndexPath *) indexPath (NSInteger) height { 
    [ myData objectAtIndex: indexPath.row ].height = height; 
    [ myTableView reloadRowsAtIndexPaths: [ NSArray arrayWithObject: indexPath ] withRowAnimation: UITableViewRowAnimationNone ]; 
} 
+0

但我不能改变行的高度时,我喜欢?只有当TableViewController“询问”它时 – 2010-05-04 17:49:28

+1

只需使用一个元素“NSArray”调用'reloadRowsAtIndexPaths'。 – 2010-05-04 18:05:55

+0

你想坚持细胞高度? – 2010-05-04 18:19:52

1
+0

他要求动态地改变高度的动画。 heightForRowAtIndexPath在表设置之前运行,不会在用户交互时更改高度。 – 2010-05-04 22:28:57

+0

是的......你说得对。我的回答并不包括他的需求。 – 2010-05-04 22:38:00

相关问题