2013-01-25 57 views
1

我在xcode 4.5中使用了storyboard。以編程方式調整tableview高度

在我的應用程序中有2個視圖,view1和view2。

每個視圖都有一個tableview。

導航控制器連接到視圖。

我想改變桌面的高度取決於Iphone顯示器的大小。

我使用下面的代碼:

- (void)viewDidAppear:(BOOL)animated { 

[super viewDidAppear:animated];  

// Verify if the screen is iphone 5 

if ([[UIScreen mainScreen] bounds].size.height == 568){ 

    // Resize table hight 

    CGRect tvframe = [_myTableView frame]; 
    [_myTableView setFrame:CGRectMake(tvframe.origin.x, 
             tvframe.origin.y, 
             tvframe.size.width, 
             tvframe.size.height + 64)]; 
} 

的問題是,該代碼沒有任何影響應用程序啓動並出現廠景時。

但是,當我移動到view2,然後回到view1調整大小生效。

我不明白爲什麼應用程序啓動時reszing不起作用。

回答

0

您是否嘗試將代碼移到ViewWillAppear?這應該解決問題。

+0

將代碼移到ViewWillAppear不起作用。 我通過創建單獨的視圖解決了這個問題,這些視圖用於Iphone 3/4和Iphone 5。 – Oualid

相關問題