監(jiān)控手機(jī)屏幕旋轉(zhuǎn)的通知

- (void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];

//旋轉(zhuǎn)屏幕通知

[[NSNotificationCenter defaultCenter] addObserver:self

selector:@selector(onDeviceOrientationChange)

name:UIDeviceOrientationDidChangeNotification

object:nil

];

}

/**

*? 旋轉(zhuǎn)屏幕通知

*/

- (void)onDeviceOrientationChange{

if (wmPlayer==nil||wmPlayer.superview==nil){

return;

}

UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;

UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;

switch (interfaceOrientation) {

case UIInterfaceOrientationPortraitUpsideDown:{

NSLog(@"第3個(gè)旋轉(zhuǎn)方向---電池欄在下");

}

break;

case UIInterfaceOrientationPortrait:{

NSLog(@"第0個(gè)旋轉(zhuǎn)方向---電池欄在上");

if (wmPlayer.isFullscreen) {

if (isSmallScreen) {

//放widow上,小屏顯示

[self toSmallScreen];

}else{

[self toCell];

}

}

}

break;

case UIInterfaceOrientationLandscapeLeft:{

NSLog(@"第2個(gè)旋轉(zhuǎn)方向---電池欄在左");

wmPlayer.isFullscreen = YES;

[self setNeedsStatusBarAppearanceUpdate];

[self toFullScreenWithInterfaceOrientation:interfaceOrientation];

}

break;

case UIInterfaceOrientationLandscapeRight:{

NSLog(@"第1個(gè)旋轉(zhuǎn)方向---電池欄在右");

wmPlayer.isFullscreen = YES;

[self setNeedsStatusBarAppearanceUpdate];

[self toFullScreenWithInterfaceOrientation:interfaceOrientation];

}

break;

default:

break;

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容