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.