|
@@ -101,15 +101,31 @@ typedef NS_ENUM(NSInteger, ACCOMPANYACTION) {
|
|
|
|
|
|
@implementation NewClassRoomViewController
|
|
|
|
|
|
+- (void)changeOrientation:(BOOL)isLandScape {
|
|
|
+ if (isLandScape) {
|
|
|
+ // 切换到横屏
|
|
|
+ AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
+ delegate.allowAutoRotate = YES;
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight inController:self];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 切换到横屏
|
|
|
+ AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
+ delegate.allowAutoRotate = NO;
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait inController:self];
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
#pragma mark - Life cycle
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
[super viewWillAppear:animated];
|
|
|
self.zh_statusBarHidden = YES;
|
|
|
// 切换到横屏
|
|
|
- AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
- delegate.allowAutoRotate = YES;
|
|
|
- [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight];
|
|
|
+ [self changeOrientation:YES];
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
|
[RCRTCEngine sharedInstance].statusReportDelegate = self;
|
|
|
}
|
|
@@ -121,9 +137,7 @@ typedef NS_ENUM(NSInteger, ACCOMPANYACTION) {
|
|
|
[self removeAll];
|
|
|
}
|
|
|
// 竖屏
|
|
|
- AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
- delegate.allowAutoRotate = NO;
|
|
|
- [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait];
|
|
|
+ [self changeOrientation:NO];
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
self.zh_statusBarHidden = NO;
|
|
|
[self hideAlertView];
|
|
@@ -164,9 +178,7 @@ typedef NS_ENUM(NSInteger, ACCOMPANYACTION) {
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(quitRoomAction) name:@"classroomQuit" object:nil];
|
|
|
|
|
|
// 切换到横屏
|
|
|
- AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
- delegate.allowAutoRotate = YES;
|
|
|
- [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight];
|
|
|
+ [self changeOrientation:YES];
|
|
|
[self addSubviews];
|
|
|
[self bindDelegates];
|
|
|
[self publishStream];
|
|
@@ -436,7 +448,12 @@ typedef NS_ENUM(NSInteger, ACCOMPANYACTION) {
|
|
|
|
|
|
} error:^(RCRTCCode code) {
|
|
|
[self.hud hideAnimated:YES];
|
|
|
- [self.tipsView showTipsMessage:@"切换线路失败!" inView:self.view];
|
|
|
+ if (code == RCRTCCodeAudioDeviceStartError) {
|
|
|
+ [self.tipsView showTipsMessage:@"音频设备启动失败,请重启设备后重试!" inView:self.view];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.tipsView showTipsMessage:@"切换线路失败!" inView:self.view];
|
|
|
+ }
|
|
|
}];
|
|
|
}
|
|
|
|