Video playback want full screen, using the Shouldautorotate method to prohibit the main interface, Tabbar controller horizontal screen, causing push to enter the playback page can not cross-screen problem ...
-(BOOL) shouldautorotate {
return NO;
}
-(Uiinterfaceorientationmask) supportedinterfaceorientations {
return uiinterfaceorientationmaskall;
}
The following workaround:
-(void) Fullscreenclick: (UIButton *) Sender {
sender.selected =!sender.selected;
if (sender.isselected) {
_backbutton.hidden = YES;
[Self forceorientationlandscapeleft];
} else {
_backbutton.hidden = NO;
[Self forceorientationportrait];
}
}
MARK:--Force horizontal screen
-(void) Forceorientationlandscapeleft
{
Appdelegate *appdelegate= (Appdelegate *) [uiapplication sharedapplication].delegate;
Appdelegate.isforceportrait=no;
Appdelegate.isforcelandscape=yes;
[Appdelegate application:[uiapplication sharedapplication] Supportedinterfaceorientationsforwindow: Self.view.window];
Yncnavigationviewcontroller *navi = (Yncnavigationviewcontroller *) Self.navigationcontroller;
Navi.interfaceorientation = Uiinterfaceorientationmasklandscape;
Navi.interfaceorientationmask = Uiinterfaceorientationmasklandscape;
Set the screen's turn to horizontal screen
[[Uidevice Currentdevice] setvalue:@ (uideviceorientationlandscapeleft) forkey:@ "orientation"];
Refresh
[Uiviewcontroller attemptrotationtodeviceorientation];
}
MARK:--Force vertical screen
-(void) forceorientationportrait
{
Appdelegate *appdelegate= (Appdelegate *) [uiapplication sharedapplication].delegate;
Appdelegate.isforceportrait=yes;
Appdelegate.isforcelandscape=no;
[Appdelegate application:[uiapplication sharedapplication] Supportedinterfaceorientationsforwindow: Self.view.window];
Yncnavigationviewcontroller *navi = (Yncnavigationviewcontroller *) Self.navigationcontroller;
Navi.interfaceorientation = uiinterfaceorientationportrait;
Navi.interfaceorientationmask = uiinterfaceorientationmaskportrait;
Set the screen's turn to portrait screen
[[Uidevice Currentdevice] setvalue:@ (uideviceorientationportrait) forkey:@ "orientation"];
Refresh
[Uiviewcontroller attemptrotationtodeviceorientation];
}
#import <UIKit/UIKit.h>
@interface Appdelegate:uiresponder <UIApplicationDelegate>
@property (Strong, nonatomic) UIWindow *window;
@property (Assign, nonatomic) BOOL Isforcelandscape;
@property (Assign, nonatomic) BOOL isforceportrait;
@end
Appdelegate.m
-(Uiinterfaceorientationmask) Application: (UIApplication *) application Supportedinterfaceorientationsforwindow: ( UIWindow *) window{
if (Self.isforcelandscape) {
return uiinterfaceorientationmasklandscape;
}else if (self.isforceportrait) {
return uiinterfaceorientationmaskportrait;
}
return uiinterfaceorientationmaskportrait;
}
@interface Yncnavigationviewcontroller:uinavigationcontroller
Rotation direction Default vertical screen
@property (nonatomic, assign) uiinterfaceorientation interfaceorientation;
@property (nonatomic, assign) Uiinterfaceorientationmask Interfaceorientationmask;
@end
. m
#pragma mark-Control your own turn-screen logic with a child controller
-(BOOL) shouldautorotate {
return YES;
}
-(Uiinterfaceorientationmask) supportedinterfaceorientations {
return self.interfaceorientationmask;
}
-(uiinterfaceorientation) preferredinterfaceorientationforpresentation {
return self.interfaceorientation;
}
IOS-Video playback handles full screen/horizontal screen when you meet the pit