Today spent a day on the IOS6 and IPHONE5 adaptation [due to their own machine is IPHONE5, so there is no problem, but in IPHONE4 on the problem, are IOS7 version, there is a IOS6 version of the ipod, there is a problem ~ Ah, at the beginning did not pay attention to the matching , now have to spend this energy to modify ~ Special summary, to prevent future mistakes, improve work efficiency, refueling! ]
Because of the habit problem, viewdidload in the view controller to create a custom UI element, because the iOS version problem, so Self.view.frame will be different, if you want to implement the same UI layout, test with code, found the following 4 cases
3.5 inch iphone
Iphone5,iphone5s Equipment
Conclusion: For a view controller with a navigation bar, IOS6 system under Self.view subviews ORIGIN.Y is calculated from the bottom of the navigation bar, height is the entire screen height minus 20 after the value of the reference, IOS7 system is calculated from 0, height is the entire screen height as a reference!
A discussion on the adaptation scheme:
1. In the viewdidload of each view controller to determine the iOS version and iphone size, create a different frame, to set up each UI element [current due to time issues, to take this approach, found a little cumbersome, difficult to maintain]
2. Add the following code under each view controller:
1 if 7 ) {2 self.edgesforextendedlayout = uirectedgenone; 3 }
View Code
So no matter in the IOS6 or IOS7, the elements of the ORIGIN.Y are the same, do not have to set up a separate
Then as long as you control the height of each element is OK, such as:
3. Under the premise of the second method, rewrite the Loadview method under each view controller
1 -(void ) Loadview 2 { [ Super Loadview]; 4 cgrect rect= [[UIScreen Mainscreen] Applicationframe]; 5 uiview* view=[[uiview Alloc] initWithFrame: RECT]; 6 view.backgroundcolor=[uicolor Purplecolor]; // 7 self.view=view; 8 [view release]; 9 }
View Code
In this way the height of the second method can be set to set the same, do not set the ~ ~
The height is referenced by the value minus 20 of the screen height
Well, the current summary is this, did not read the description on the Internet, all self-elaboration, perhaps there will be a better solution, welcome everyone to put forward! Originally only to enter the iOS development camp soon, before doing WP and WIN8 development, also welcome small partners Exchange ~ Always have a Microsoft Powder heart Ah!