Interface Builder, frame changes on IOS 6

2019-08-21 10:55发布

问题:

I have a xib file that support IOS 6 and 7.

The problem is when i selected view as IOS 6 the frame from IOS 7 change, and vice versa. Here is a screenshot, previewing the IOS 6.1.

I adjust the frame to (0, -3, 255, 85) and when adjust the frame using view as IOS 7 the frame becomes: (-345,894,0,0). When i adjust the frame using view as IOS 6.1 and early the frame changes for IOS 7.

I just want to use the same frame in both IOS version.

Some informations that may be relevant:

Was an existing project build for IOS 5.1 and later, then i update the project to support IOS 7. When i made the update some views (include this one) have their frame changed to positions that does not make any sense and size their size set (0,0).

First i think was an interface builder issue preview issue, but i tested on devices with IOS 6 and 7 and the results are the same from the preview

Thanks in advanced!

回答1:

When you assign bottom margin & top margin in Autoresizing tab, iOS 7 gets confused & produces strange effects.

I faced the same problem, & i solved it using height stretch. Refer image.



回答2:

Use 'iOS 6/7 deltas' fields to adjust design element(s) position on your controller for different iOS.

You should setup your project (setup how UI view) for one of iOS versions (6.1 or earlier/7.0 or later) and then adjust interface by deltas to other version.

You also can use new preview mode to see difference between two operation systems on one screen.

Here is link to APPLE iOS 7 transition guide - https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TransitionGuide/SupportingEarlieriOS.html#//apple_ref/doc/uid/TP40013174-CH14-SW1



回答3:

First set your view size as none and then Set your frame using view as iOS 6.1 and earlier. Now test in iOS 6 and 7. It will automatically resize your view frame.