附一段解决方案,在原生代码里,旋转之前将屏幕方案设置成未知的,然后再设置自己想要的方向。如果用户锁定了屏幕方案,此方法依然有效。
+(void)setOrientation:(NSString*)dir{
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationUnknown] forKey:@"orientation"];
if([dir isEqualToString:@"V"]){
oMask = UIInterfaceOrientationMaskPortrait;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"];
}
else{
oMask = UIInterfaceOrientationMaskLandscape;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationLandscapeRight] forKey:@"orientation"];
}
}