IOS8 screen Rotation problem

Source: Internet
Author: User

Judge the screen vertically. http://www.cocoachina.com/ask/questions/show/121301

//Self.cameraview is the camera view-(Nsuinteger) supportedinterfaceorientations{uiinterfaceorientation e=[[UIApplication sharedapplication] statusbarorientation]; if(E = =uiinterfaceorientationlandscapeleft) {                if(Self.cameraview) {Self.cameraView.transform= Cgaffinetransformmakerotation (- the* M_PI)/180.0f); }    }Else if(E = =uiinterfaceorientationlandscaperight) {                if(Self.cameraview) {Self.cameraView.transform= Cgaffinetransformmakerotation (( the* M_PI)/180.0f); }            }    return(Uiinterfaceorientationmasklandscape);} - (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view. //M_bscreen is a bool type, judging the screen.     if([[[[Uidevice currentdevice]systemversion]floatvalue] >=8.0) {BOOL M_bscreen=NO; Uiinterfaceorientation e=[[UIApplication sharedapplication] statusbarorientation]; if(E = =uiinterfaceorientationlandscapeleft) {M_bscreen=NO; }Else if(E = =uiinterfaceorientationlandscaperight) {M_bscreen=YES; }        if([[Uidevice Currentdevice] Respondstoselector: @selector (setorientation:)]) {NSNumber*num = [[NSNumber alloc] Initwithint: (m_bscreen?Uiinterfaceorientationlandscaperight:uiinterfaceorientationlandscapeleft)]; [[Uidevice Currentdevice] Performselector: @selector (setorientation:) Withobject: (ID) num]; [Uiviewcontroller attemptrotationtodeviceorientation];//This line of code is key} SEL Selector=nsselectorfromstring (@"setorientation:"); Nsinvocation*invocation =[Nsinvocation Invocationwithmethodsignature:[uidevice instancemethodsignatureforselector:selector];                [Invocation setselector:selector];                [Invocation Settarget:[uidevice Currentdevice]; intVal =m_bscreen?Uiinterfaceorientationlandscaperight:uiinterfaceorientationlandscapeleft; [Invocation setargument:&val Atindex:2];    [Invocation invoke]; }        }

How to get camera view:

#pragmaMark Uinavigationcontrollerdelegate-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: (UIViewController *) Viewcontroller animated: (BOOL) animated{if([[[[Uidevice currentdevice]systemversion]floatvalue] >=8.0) {UIView*plcameraview=[self FindView:viewController.view Withname:@"Plimagepickercameraview"]; Nsarray*svarray =[Plcameraview subviews]; Self.imagePickerController.cameraView = svarray[0];  for(inti =1; i < Svarray.count; i++) {//i:0 camera 1 Photo screen 2 re-pat interface            if(i = =1) {Nsarray*arr = [svarray[1] subviews];  for(inti =0; i < Arr.count; i++) {                    if(i = =9) {//i:1 front-facing camera switch[arr objectatindex:i] Setalpha:0.0f]; }                }            }        }    }Else if([[[[Uidevice currentdevice]systemversion]floatvalue] >=7.0) {UIView*plcameraview=[self FindView:viewController.view Withname:@"Plcameraview"]; Nsarray*svarray =[Plcameraview subviews];  for(inti =1; i < Svarray.count; i++) {//i:0 camera 1 Photo screen 2 re-pat interface            if(i = =1) {Nsarray*arr = [svarray[1] subviews];  for(inti =0; i < Arr.count; i++) {                    if(i = =1) {//i:1 front-facing camera switch[arr objectatindex:i] Setalpha:0.0f]; }                }            }        }    }}#pragmaMark Get/show the UIView we want//Find The view we want in camera structure.-(UIView *) Findview: (UIView *) Aview withname: (NSString *) name{Class cl= [Aviewclass]; NSString*desc =[cl description]; if([name Isequaltostring:desc])returnAview;  for(Nsuinteger i =0; i < [aview.subviews count]; i++) {UIView*subview =[Aview.subviews objectatindex:i]; SubView=[self findview:subview withname:name]; if(SubView)returnSubView; }    returnNil;}

IOS8 screen Rotation problem

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.