2015-06-21 90 views
1

我想通过点击一个按钮来使屏幕旋转。但是,由于布局复杂,我使用sizeClass,我不打算通过设置视图的变换来实现它。所以我可以调用系统的方法。如果是的话,以及如何?我可以调用系统的自动旋转方法吗?

+0

那么你可以覆盖,但用户仍然必须打开设备,并手动触发它,如果你不想让它变得像超级错综复杂。 – LinusGeffarth

+0

@LinusG。我知道了!所以最好的解决方案是设置视图的变换? – elephant

+0

你是什么意思? – LinusGeffarth

回答

0

试试这个:

if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) 
{ 
    objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait); 
} 

然而,这是一个私人的API。

+0

所以我必须设置视图的变换来实现它? – elephant

相关问题