2014-10-29 76 views
0

我已经使用下面的代码强制视图到风景。旋转到风景的视图 - iOS

objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft); 

是苹果批准此为定位或有机会拒绝我的app.Please提供您的解决方案。

回答

0

我不这么认为。 Apple documentation指出方向是只读属性。

要强制景观融为一体的ViewController,你可以这样做:

- (NSUInteger)supportedInterfaceOrientations; 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

呈现的ViewController在一个特定的方向模式:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation; 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 

对于所有这些情况发生,该项目的plist绝支持方向和:

- (BOOL)shouldAutorotate; 
{ 
    return YES; 
} 

所有这些都假设视图控制ller不在相同的UINavigationController下提供。对于这样的情况下,你应该参考这个讨论解决办法迫使旋转上的UINavigationController:UINavigationController Force Rotate

对于要强制到横向视图,您可以随时使用变换:

self.view.transform = CGAffineTransformMakeRotation(M_PI/2.0); 
+0

感谢您的建议。Anyway苹果已经通过objc_msgSend批准了我的应用程序。 – Thangavel 2014-11-27 14:50:14