2012-05-24 193 views
1

我的視圖最初處於橫向模式。當一個按鈕被錄音時,一個視圖將以縱向模式打開,並且所有內容都可以在這一點上找到。問題是當我從該視圖返回到根視圖時視圖將無法正確旋轉。這裏是我使用的旋轉從縱向到橫向視圖中的代碼,iPad從縱向轉爲橫向

-(void)viewWillDisappear:(BOOL)animated 
{ 
[super viewWillDisappear:animated]; 

//rotate the page to lansscape 
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(-90*0.0174532925); 
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0); 

[self.navigationController.view setTransform:landscapeTransform]; 

self.navigationController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;  
self.navigationController.view.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height); 
self.navigationController.view.center = CGPointMake (384.0, 544.0); 

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; 
} 

這裏是風景模式根頁面的屏幕截圖從縱向頁面返回後,

enter image description here

這是應該什麼樣子

enter image description here

+0

檢查您的xib方向視圖。 – Santhosh

+0

當然是風景! – Mona

回答

1
-(void)viewWillDisappear:(BOOL)animated 
{ 

[super viewWillDisappear:animated]; 

//rotate the page to lansscape 
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(-90*0.0174532925); 
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0); 

[self.navigationController.view setTransform:landscapeTransform]; 

self.navigationController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;  
self.navigationController.view.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height+64); 
self.navigationController.view.center = CGPointMake (384.0, 512.0); 

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; 

} 

,我不得不打轉轉之後這一觀點是在肖像模式下消失是這樣的調整這是出現的景觀視野的東西,

self.navigationController.view.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height+64); 
self.navigationController.view.center = CGPointMake (384.0, 512.0); 

我與中心點和框架高度調整發揮各地它。

相關問題