Adaptation of iOS6 and iOS7 code (3) -- coordinate adaptation

Source: Internet
Author: User

The status bar and view in iOS7 overlap, so the y coordinate of the application cannot be the same as before. You need to recalculate the settings. Basically, you can see this problem after running Xcode5. Here is a simple example. A Label control is added to a View, they are displayed on the iOS6 and iOS7 simulators respectively.


From the figure, we can see that the start point of y coordinate calculation on iOS7 is counted from the screen vertex, and iOS6 is counted from the status bar, which is the root cause of all problems. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + 0tb25/Signature + signature + B/J0tTIw7 + signature/Signature/sDvw + bq3366evls/Signature + vP87XEstC/Signature/V4tH51/Signature + sHLvMzQ + weight + Mi4gyta2r9DeuMTX + weight + tcTRp9S6xcm8q7/weight + Weight = "http://www.bkjia.com/uploadfile/Collfiles/20140107/20140107141052241.png" alt = "\">

In this way, all the controls in IB will change to the iOS6 style, but the running system on iOS7 will still use the iOS7 Control for display, and the coordinates are still incorrect-it seems that it does not work at all. Well, this is only the first step. You don't have to worry about it. You can achieve adaptation by doing another step!

Modify the DeltaY value according to your actual situation. Here, it is clearly the height of the status bar, with 20 pixels.


Run the application to see if viewController has been adapted?

This method is simple and intuitive, but it needs to be adapted one by one in multiple viewcontrollers. However, the overall workload is not great, the adaptation effect is also good, and there is no problem with rotating the screen, etc, so my application finally adopted this method to adapt, and the actual workload is not large.

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.