Ios 6 and ios 7 adaptation issues, allowing the program to support both iOS 6 and iOS 7, setEdgesForExtendedLayout, layout

Source: Internet
Author: User

Ios 6 and ios 7 adaptation issues, allowing the program to support both iOS 6 and iOS 7, setEdgesForExtendedLayout, layout

For various reasons, our program needs to support both iOS 7 and earlier versions (such as iOS 6), that is, developers have to develop between iOS 7 and iOS 6 at the same time. In fact, developers hate this.

Layout problems in iOS 7

The following is a very simple program running on iOS 6:

If you run it on iOS 7 simulator, you will not see the label:

Why? Let's take a look at its reveal:

As you can see, the label is actually behind the NavigationBar. In iOS 7, Apple introduced a new property called[UIViewController setEdgesForExtendedLayout:]The default value isUIRectEdgeAll. When your container is a navigation controller, the default layout starts from the top of the navigation bar. This is why all the UI elements drift up 44pt.

The quick way to fix this problem is- (void)viewDidLoadAdd the following line of code:

1
self.edgesForExtendedLayout = UIRectEdgeNone;

In this way, the problem is fixed.

IOS 6 running exception

If you run a program on iOS 6, the following exception occurs:

1
[LAViewController setEdgesForExtendedLayout:]: unrecognized selector sent to instance 0x778a210

All the APIs that can only be run in iOS 7 need to be re-encapsulated, as shown in the following code:

1234
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]){    self.edgesForExtendedLayout = UIRectEdgeNone;}
Xcode 4 Compilation Error

Some machines may still use Xcode 4.6. When using 4.6 to compile code, the following compilation error occurs:

12
Property 'edgesForExtendedLayout' not found on object of type 'LAViewController *'Use of undeclared identifier 'UIRectEdgeNone'

To avoid this error, you can create the following macro:

123
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000#define IOS7_SDK_AVAILABLE 1#endif

Then, wrap the iOS 7 code as needed:

123
#ifdef IOS7_SDK_AVAILABLE...#endif
Inconsistent UILabel background

For UILabel, in iOS 7, its background color is clearColor by default, while in iOS 6, the background color is white by default. Therefore, we 'd better set the label's background color in the Code:

1
view.backgroundColor = [UIColor clearColor];
Hide the status bar in full screen mode

In iOS 6, whenpresentViewControllerThe default modal screen will be full screen (UIModalPresentationFullScreen). To achieve the same effect in iOS 7, we can add the following code in modal controller:

1234
- (BOOL)prefersStatusBarHidden{  return YES;}
UIToolbar barStyle

Sometimes we can combine the UIToolbar with the system keyboard. In iOS 6, the keyboard is dark, and the style of the toolbar is similar, as shown in the following code:

1
self.barStyle = UIBarStyleBlack;// or UIBarStyleBlackTranslucents

In iOS 7, the keyboard changes to a brighter color, so we need to set different bar styles based on different iOS versions.

12345678
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending){    self.barStyle = UIBarStyleDefault;}else{    self.barStyle = UIBarStyleBlack;//or UIBarStyleBlackTranslucent}
More

The above skills are what I have encountered in development, and there are certainly more skills. If you know, let me know.

Finally, let's take a look at the differences:


IOS613 is there any plug-in that can enable the background program to call up the background directly like iOS70, and then close the process up.

Auxo, but stable. We recommend that you use and disable multi-task gestures with zephyr.
This plug-in is very powerful. You can find it online for details.
 
IPHONE problems: problems that occur when ios7 is swiped back to ios613

Hello! You are iTuesn. Press shift and click "Update" + 6.1.3? (This will cause activation failure)
ITuesn holding down shift and clicking "Restore" + 6.1.3 is the correct method. You can try again.
If this is not the case, use the AISI assistant-one-click flash brush-select the firmware (6.1.3)-instant flash brush (in DFU mode ).

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.