iOS UITableView cell and section height

TableView在iOS4所寫相同的Code,在iOS5 build起來卻有不同的結果,最後找出原因在iOS4以前TableView預設的section高度為0(簡單來說就是看不到),但在iOS5卻為預設高度(好像是20,剛好一行字)。上架(Apple Store)後並不會出現這問題,所以若已經確定為上架版本可以放心。

iOS5上需要特別去修正過section的高度來讓他消失,此function回傳值即為section的高度。
//section height
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.0;
}


修改Cell高度即為
//cell height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
//set cell size
return 100.0;
}


相關連結
iOS Developer Library
iOS Developer Library - UITableView
iOS Developer Library - UITableViewController

沒有留言:

張貼留言