[IOS] allows your app to quickly adapt to iPhone 5

Source: Internet
Author: User

First, we need an xcode version with a higher level. Now we usually need more than 4.5, and then run your application in the simulator, choose hardware> device> iPhone (retina 4-inch), which is the resolution of iPhone 5.

If no application has been adapted, a Black edge will appear at both the upper and lower ends,

So how to adapt?

1. First click a startup image, and the image name is default-568h@2x.png. After the image is set, start the image and you will find that the two black edges are missing.

2. the screen height of 3.5-inch is 480, and the height of 4.0-inch is 568. Therefore, you have to reset the hard-coded cgrect, cgpoint, and cgsize fields, generally, there are two ways: one is to calculate by relative coordinates, and the other is to determine the screen size and separate settings.

For example:

(1). Calculate by relative coordinates

CGSize size = [[UIScreen mainScreen] bounds].size;
view.frame = CGRectMake(0, 44 , 320, size.height - 44)

(2) determine the screen size and separate settings.

# Define device_is_iphone5 ([[uiscreen mainscreen] bounds]. Size. Height = 568) if (device_is_iphone5) {[Button setframe: cgrectmake (0,538,320,440)];} else {
 [button setFrame:CGRectMake(0,450, 320, 440)];  

}

3. For the XIB layout Interface

Check the use autolayout check box of viewcontrol. Of course, check to select another autoresize subviews item.

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.