2010-12-17 21 views
3

我在我的ipad應用程序中實現了具有兩個視圖的主視圖和詳細視圖的splitviewcontroller。在改變ipad從縱向到橫向的方向時,我需要隱藏主視圖並將詳細視圖的幀大小更改爲全屏顯示。爲此,我使用此代碼。splitviewcontroller的詳細視圖的幀大小不會在ios4.2中改變

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
     //adjust master view 
     UIViewController *master = [self.splitViewController.viewControllers objectAtIndex:0]; 
     UIViewController *detail = [self.splitViewController.viewControllers objectAtIndex:1]; 
     CGRect t = master.view.frame; 
     t.size.width = 0; 
     t.size.height = 0; 
     t.origin.x = 0; 
     t.origin.y = 0; 
     [master.view setHidden:YES]; 
     [master.view setFrame:t]; 

     //adjust detail view 
     CGRect f = detail.view.frame; 
     f.size.width = 1004; 
     f.size.height = 768; 
     f.origin.x = 0; 
     f.origin.y = 0; 

     [detail.view setFrame:f]; 

} 

此代碼在ios3.2上工作得很好,但不適用於ios4.2。主視圖隱藏在ios4.2中,但細節視圖的框架大小不會更改。

請幫幫我。 由於 思魯提

回答

0

,我發現我的問題另一種方法是,代替隱藏主視圖和改變細節視圖的幀大小上旋轉我只呈現含有細節視圖作爲模態的視圖的類。早些時候,我推動了上一堂課。我還用一個完成按鈕添加了一個導航欄來消除模態視圖。這件事對我有用。

ListingViewController *viewController = [[ListingViewController alloc] initWithNibName:@"ListingViewController" bundle:[NSBundle mainBundle]]; 
UINavigationController *modalVC = [[UINavigationController alloc]initWithRootViewController:viewController]; // to add navigation bar 
modalVC.navigationBar.barStyle = UIBarStyleBlackOpaque; 
[self.navigationController presentModalViewController:modalVC animated:YES]; 
[modalVC release]; 
[viewController release]; 
+0

這只是我所做的解決我的問題的替代方案。它不完全是問題的答案。 – Aisha 2010-12-22 06:58:54

相關問題