Calling the appropriate setStatusBarHidden per iOS version

前端 未结 4 1249
心在旅途
心在旅途 2020-12-16 02:02

Today my app approved, but I got emails from users says it crash. I figured out that

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:         


        
4条回答
  •  情书的邮戳
    2020-12-16 02:12

    I'd recommend you to use the following snipplet of code instead of checking against the version of the os, rather check if a selector is currently available.

    if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: withAnimation:)])
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    else 
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
    

提交回复
热议问题