Iphone Development supports device Rotation

Source: Internet
Author: User

 

To support device rotation, do the following:

Override the "shouldAutorotateToInterfaceOrientation:" method of the corresponding View Controller and declare the supported direction in the method. That is, first rewrite the "shouldAutorotateToInterfaceOrientation:" method in "Hello_WorldViewController.m ".

Configure the autoresizingMask attribute of the View in the corresponding View Controller to adapt to layout changes caused by PAGE rotation. That is, you must set the autoresizingMask attribute of the Label control.

In the interface file, select the Label. On the size and position settings page, click the Red Line in Autosizing to set the Label to automatically adjust the width and height of the top, bottom, and left directions, in this way, after the device is rotated, the width and height of the interface are changed, and the position, length, and width of the upper, lower, and left directions of the control are also adjusted, the text is centered and aligned inside the Label to ensure that the text is displayed in the center of the interface.

Click the "Hide or show the Navigator" and "Hide or show the Utilities" buttons on the toolbar to display the left Navigator area, Hide the Utility area, and select the "Hello_WorldViewController.m" file in the left Navigator area, find the "shouldAutorotateToInterfaceOrientation:" method and rewrite it. After rewriting, the Code is as follows:

 

-(BOOL) shouldAutorotateToInterfaceOrientation :( UIInterfaceOrientation) interfaceOrientation

{

// Return YES for supported orientations

Return YES;

}

Save the changes, run the project, and bring up the simulator. Call the simulator's device rotation menu to turn the iPhone simulator into a horizontal screen. The text will automatically adjust the position, or in the center of the screen.

From: iphone Development

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.