开发者

iPhone 4.0 compatibility issue

开发者 https://www.devze.com 2023-01-08 21:49 出处:网络
I am developed one iPhone application which is working good in iphone 3.0. While i am doing comparab开发者_Go百科ility with 4.0 it is giving some deprecated workings.

I am developed one iPhone application which is working good in iphone 3.0.

While i am doing comparab开发者_Go百科ility with 4.0 it is giving some deprecated workings.

Please find the code below.....

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

Note: this is working fine in 3.0 but giving warning in 4.0

[[UIApplication sharedApplication] setStatusBarHidden:YES
                                        withAnimation:UIStatusBarStyleDefault];

Note: this is working fine in 4.0 but not at all working in 3.0.

My coding part almost completed, I need to publish this application ASAP.

Please help me out in this issue.

Thanks in advance.


You have two main options:

  1. if you use setStatusBarHidden:animated: in 4.0, it will work. It's deprecated, which means you should avoid it, but it will still work — for now.

  2. Check at runtime which one is the best option:

if ([UIApplication instancesRespondToSelector:@selector(setStatusBarHidden:withAnimation:)]) {
    // use 4.0 method
} else {
    // use 3.0 method
}


The poper way of handling such issues is using the ‘instancesRespondToSelector‘ method to check out which version you are running on. There is a possibility to use also a pre compiler directive, but introspection is the way Apple recommends.

So check if the UIApplication object responds to the setStatusBarHidden:withAnimation selector Nd execute the 4.0 code otherwise call the 3.0 code.

0

精彩评论

暂无评论...
验证码 换一张
取 消