2011-07-19 65 views
0

我正在研究頂部有一個mapview和底部有一個表視圖的項目,我試圖使應用程序可以調整到不同的視圖方向通過使用以下碼,當從縱向更改爲橫向視圖時,表視圖消失xcode

- (BOOL)shouldAutorotateToInterfaceOrientation:  
(UIInterfaceOrientation)interfaceOrientation 
{ 


    return YES; 
} 

但是當我從縱向更改視圖以景觀查看錶視圖獲取dissappeared, 我怎樣才能使這項工作,任何幫助將不勝感激

請多關照,

回答

0

桌面視圖隱藏在橫向視圖下方,我必須對桌面視圖的位置和高度進行硬編碼,才能在縱向和橫向視圖上顯示相同高度和位置

- (BOOL)shouldAutorotateToInterfaceOrientation:  (UIInterfaceOrientation)interfaceOrientation 
{ 
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { 
    CGRect tableViewFrame = [tableView frame]; 
    tableViewFrame.origin.x = 0; 
    tableViewFrame.origin.y = 500;   
    tableViewFrame.size.height=500; 
    [tableView setFrame:tableViewFrame]; 
} 
else if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)){ 
    CGRect tableViewFrame = [tableView frame]; 
    tableViewFrame.origin.x = 0; 
    tableViewFrame.origin.y = 755;   
    tableViewFrame.size.height=500; 
    [tableView setFrame:tableViewFrame]; 
} 

return YES; 
} 
相關問題