2010-05-04 83 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

相關問題