IOS-Video playback handles full screen/horizontal screen when you meet the pit

Source: Internet
Author: User
Tags uikit

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.