2015-05-28 21 views
0

我在桌面視圖中有15行這個表是動態表,但我想第5行和第11行到第20行(這是幻燈片菜單中的主題菜單)。我在故事板編輯,但它不會改變。如何在桌面視圖中編輯一些行高

+1

使用'heightForRowAtIndexPath:'方法。請參閱這裏http://stackoverflow.com/questions/3737218/tableview-cell-height-how-to-customize-it – Akhilrajtr

回答

2

只要把條件在這裏:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if(indexPath.row == 5){ 
     return 20; 
    } 
    else{ 
     return 71.0; 
    } 
} 
+1

它的作品謝謝你。 –

+0

隨時歡迎:) @YasuhiroKondo –

0

實施heightForRowAtIndexPath代表。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath  *)indexPath; 
{ 
    CGFloat rowHeight = 10.0; 

    if(0 == indexPath.section && (5 == indexPath.row || 11 == indexPath.row)) 
    { 
     rowHeight = 20.0; 
    } 

    return rowHeight; 
} 
0

您應該設置默認高度storyboard(這是更容易使用),如果你想爲每個小區返回不同的高度比你應該使用的UITableView以下delegate方法,並納入了條件迴歸UITableViewCell's的高度根據您的要求(在您的情況下,要求是返回第5和第11行的高度爲20其他行爲高度,假設50)。您可以這樣做 -

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(indexPath.row == 5 || indexPath.row == 11) 
     return 20.0; 
    else 
     return 50.0; 
} 
相關問題