System compatibility Problem resolution for iOS development

Source: Internet
Author: User

For outdated methods in the system or for backwards compatibility with different versions use the latest method to determine the current system version number, in making method calls

1. Outdated comments for system methods

"' OBJC

-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker didfinishpickingimage: (UIImage *) Image Editinginfo :(nsdictionary *) editinginfo Ns_deprecated_ios (2_0, 3_0);

Description method introduced in the 2.0 era, 3.0 times outdated

````

2. Compatibility solution for different versions of the system (this is good, no warning is generated)

"' OBJC

#if __iphone_os_version_min_required < __iphone_5_0
if ([Picker respondstoselector: @selector (dismissmodalviewcontrolleranimated:)]) {
[Picker Dismissmodalviewcontrolleranimated:yes Completion:nil];
}
Else
#endif
{
[Picker Dismissviewcontrolleranimated:yes Completion:nil];
}

````

3. Compatibility solution for different versions of the System 2 (easy to write but generates warnings)

"' OBJC

if ([Picker respondstoselector: @selector (imagepickercontroller:didfinishpickingmediawithinfo:)]) {
[Picker Dismissviewcontrolleranimated:yes Completion:nil];
}else{
[Picker Dismissmodalviewcontrolleranimated:yes];
}
````

System compatibility Problem resolution for iOS development

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.