(IPhone/iPad Development) presentViewController method after changes before and after SDK5.0 General Method

Source: Internet
Author: User

Before and after 5.0, the corresponding call method has changed the parameter. If a method later than 5.0 is used and cannot be used in a lower version, apple does not advocate the method used in a lower version, there is a solution

[Cpp]
AboutViewController * mAboutViewController = [[AboutViewController alloc] initWithNibName: @ "AboutViewController" bundle: nil];
 
If ([self respondsToSelector: @ selector (presentViewController: animated: completion :)]) {
[Self. navigationController presentViewController: mAboutViewController animated: YES completion: nil];
} Else {
[Self. navigationController presentModalViewController: mAboutViewController animated: YES];
}
[MAboutViewController release];
MAboutViewController = nil;

Determine when calling

Similarly, dismiss is a similar operation.


[Cpp]
If ([self respondsToSelector: @ selector (dismissViewControllerAnimated: completion :)]) {
[Self dismissViewControllerAnimated: YES completion: nil];
} Else {
[Self dismissModalViewControllerAnimated: YES];
}


Similarly, in the future, when the apple High Version sdk does not support the api of the lower version, a similar judgment can be used to solve the compatibility problem of the high and low versions.

 


From andy Pan's column

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.