IOS works by default only allows vertical screen, in a separate interface to convert vertically, screen rotation

Source: Internet
Author: User

Contains only. About the code of the screen

#import "InspectionReportViewController.h"#defineScreen_width ([UIScreen mainscreen].bounds.size.width)#defineScreen_height ([UIScreen mainscreen].bounds.size.height)@interfaceInspectionreportviewcontroller () <UIWebViewDelegate>{UIWebView*WebView; UIButton*Back ;}@end@implementationInspectionreportviewcontroller-(BOOL) shouldautorotate{returnNO;}-(uiinterfaceorientationmask) supportedinterfaceorientations{//if the interface needs to support the screen switching    returnUiinterfaceorientationmasklandscaperight |uiinterfaceorientationmaskportrait; //if the interface only supports horizontal screen//return uiinterfaceorientationmasklandscaperight;}-(void) Viewwillappear: (BOOL) animated{[Super viewwillappear:animated]; }-(void) Viewwilldisappear: (BOOL) animated{[Super viewwilldisappear:animated]; }- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.[self creatui]; //Horizontal screen comrade Uiapplicationdidchangestatusbarframenotification uideviceorientationdidchangenotification[[Uidevice Currentdevice] begingeneratingdeviceorientationnotifications]; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (deviceorientationdidchange) Name: UideviceorientationdidchangenotificationObject: nil];}-(void) creatui{Self.view.backgroundColor=[Uicolor Blackcolor]; WebView=[[UIWebView alloc] initWithFrame:self.view.bounds]; Webview.backgroundcolor=[Uicolor Blackcolor]; [WebView loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:[nsstring stringWithFormat:@"http://60.205.188.204:8087/webdcmviewer/dcmviewer.html?org_code=%@&check_id=%@", _org_code,_check_id]]]; Webview.scalespagetofit=YES; Webview.scrollView.scrollEnabled=NO;           [Self.view Addsubview:webview]; back= [MyButton buttonwithtype:uibuttontypecustom frame:cgrectmake (Screenwidth-iphonewidth ( -), Screenheight-iphonehight ( -), Iphonewidth ( -), Iphonehight ( -)) Tag:1Image@"Ic_history_ct_return"andblock:^ (MyButton *button)                    {[Self.navigationcontroller popviewcontrolleranimated:yes];    }];        [Self.view Addsubview:back]; }//Horizontal Screen- (void) deviceorientationdidchange{NSLog (@"deviceorientationdidchange:%ld",(Long) [Uidevice currentdevice].orientation); if([uidevice Currentdevice].orientation = =uideviceorientationportrait)                {[[UIApplication sharedapplication] setstatusbarorientation:uiinterfaceorientationportrait]; [UIView animatewithduration:0.1fanimations:^{self.view.transform= Cgaffinetransformmakerotation (0); Self.view.bounds= CGRectMake (0,0, Screen_width, screen_height); Webview.frame=Self.view.bounds; Back.frame= CGRectMake (Screen_width-iphonewidth ( the), Screen_height-iphonehight ( -), Iphonehight ( -), Iphonehight ( -));                               }]; //Note: uideviceorientationlandscapeleft and Uiinterfaceorientationlandscaperight}Else if([uidevice Currentdevice].orientation = =uideviceorientationlandscapeleft)              {[[UIApplication sharedapplication] setstatusbarorientation:uiinterfaceorientationlandscaperight]; [UIView animatewithduration:0.1fanimations:^{self.view.transform=cgaffinetransformmakerotation (m_pi_2); Self.view.bounds= CGRectMake (0,0, Screen_height, screen_width); Webview.frame=Self.view.bounds; Back.frame= CGRectMake (Screen_width-iphonewidth ( the), Screen_height-iphonehight ( -), Iphonehight ( -), Iphonehight ( -));                   }]; }Else if([Uidevice currentdevice].orientation==uideviceorientationlandscaperight)                {[[UIApplication sharedapplication] setstatusbarorientation:uiinterfaceorientationlandscapeleft]; [UIView animatewithduration:0.1fanimations:^{self.view.transform= Cgaffinetransformmakerotation (-m_pi_2); Self.view.bounds= CGRectMake (0,0, Screen_height, screen_width); Webview.frame=Self.view.bounds; Back.frame= CGRectMake (Screen_width-iphonewidth ( the), Screen_height-iphonehight ( -), Iphonehight ( -), Iphonehight ( -));    }]; }}/*#pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before n avigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [s]    Egue Destinationviewcontroller]. Pass the selected object to the new view controller.}*/@end

IOS works by default only allows vertical screen, in a separate interface to convert vertically, screen rotation

Related Article

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.