由于项目需要,接入小鹅SDK的直播功能,这里的直播放大的时候会调用系统的AVFullViewController,放大的时候不跟随横屏旋转。我的APP本身都是竖屏的不支持横屏,所以一开始就是设置支持横屏:
然后在APPDelegate中添加属性allowRotate控制支持的方向
// AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, assign) BOOL allowRotate;
@end
// AppDelegate.m
//此方法会在设备横竖屏变化的时候调用
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotate) {
return UIInterfaceOrientationMaskAll;
}else{
return (UIInterfaceOrientationMaskPortrait);
}
}