2013-07-05 26 views
1

的工作,我有很多意見。所以我分類我的tabbar控制器像這樣。取向不會在iOS 5中工作,這是在我的TabBar控制器應用的ios 6

-(BOOL)shouldAutorotate 
{ 

    return [[self.viewControllers lastObject] shouldAutorotate]; 
    } 

    -(NSUInteger)supportedInterfaceOrientations 
    { 
return [[self.viewControllers lastObject] supportedInterfaceOrientations]; 
} 

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
    { 
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; 
    } 

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation   { 
// Return YES for supported orientations 
//return (interfaceOrientation == UIInterfaceOrientationPortrait); 
return (UIInterfaceOrientationMaskAll); 


} 

,並在我的視圖控制器也

- (BOOL)shouldAutorotate 
{ 
return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight); 

//OR return (UIInterfaceOrientationMaskAll); 
} 

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation   { 
// Return YES for supported orientations 
//return (interfaceOrientation == UIInterfaceOrientationPortrait); 
return (UIInterfaceOrientationMaskAll); 



    } 
    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
    toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
{ 

} 
else 
{ 

} 
    } 

我的問題是方向是工作在IOS 6和IOS不工作5 謝謝。

回答

2

你應該在每一個標籤欄頁寫這個功能

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation   { 

return YES; 

} 

//使用這個只在需要

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 

//your view changing code 

} 
+0

感謝答覆是工作可以üPLZ澄清我它是如何工作和方法被稱爲第一,我完全糊塗了 – siva

+0

我還有一個問題,假設我有我的TabBar兩種觀點,如果我在第二個點擊和旋轉,回來第一個我所有的按鈕和標貼中受到干擾,是視圖將出現方法調用,當我旋轉從portriat到風景viceversa。 – siva

+0

是viewWillAppear中被調用 – Baddu

1

在您的視圖控制器添加該代碼,爲iOS 5

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

    return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait; 

} 
相關問題