iOS下你要主动调整方向使用下面的代码
void setOrientation( m )
{
NSNumber *value;
if( m == 2 )
value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
else
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
setOrientation强制转到指定的方向,不管手机所处的方向。
上方的方法在iOS 7.3,iOS8.0 iphone,iPad2 mini上传测试通过
ViewController也要重载下列方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//iOS 6方法,iOS询问你是否支持该方向interfaceOrientation ,你回答YES支持或者NO不支持
}
- (NSUInteger) supportedInterfaceOrientations{
//iOS询问你支持的方向
}
- (BOOL) shouldAutorotate {
//iOS询问你是否支持界面旋转,YES要,NO不要
}
重要:iOS在.plist中必须提前设置里要支持的方向。如果你想自己控制所有方向,就要在这里设置为所有方向全支持。
android下强制转换方向
切换到横屏
your_activity_handle.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
切换到竖屏
your_activity_handle.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
资料:
http://blog.csdn.net/jaywon/article/details/8208991
android:
http://www.cnblogs.com/bjzhanghao/archive/2012/11/09/2761897.html
http://2960629.blog.51cto.com/2950629/701227
http://gaebolg.blog.163.com/blog/static/19826906820134312050504/