2010-11-17 183 views
0

我設法手動檢測旋轉並在兩個UIViewControllers之間設置自己的旋轉效果。在第一個時候,旋轉到橫向提示第二個被手動動畫推動。狀態欄移動到正確的方向。但是,由第二個UIViewController加載的視圖不在我期望的位置。相反,狀態欄以前的左邊有餘量,底部有餘量/空間,我期待被視圖填充。手動iPhone旋轉位置不正確

How the rotation appears

(點擊放大橙色盒子是簡單地引用其中,0,0是在旋轉的UIView,CustomView)

的代碼,我用我的視圖控制器做旋轉是:

-(void)loadView { 
    CustomView *customView = [[CustomView alloc] initWithFrame:CGRectMake(0, 20, 480, 300)]; 
    self.view = customView; 

    CGAffineTransform rotate = CGAffineTransformMakeRotation(degreesToRadian(90)); 
    [self.view setTransform:rotate]; 

    [customView release]; 
} 

任何幫助將不勝感激!

編輯經過多種試驗和錯誤方法後解決 - 下面提供了答案。也許有一個更優雅/明顯的解決方案,但如果願意提供!

回答

0

我設法改造後設置視圖邊界來解決這個問題:

self.view.bounds = CGRectMake(20, -20, 480, 300); 
0

在視圖控制器上試試這些。解決了我獲得全屏子視圖時出現的20像素(狀態欄高度)剪輯問題。

[viewcontroller1.view setCenter:CGPointMake(viewcontroller1.view.center.x,viewcontroller1.view.center.y-20)];

和/或

[viewcontroller2.view setCenter:CGPointMake(viewcontroller2.view.center.x-20,viewcontroller2.view.center.y)];