respondsToSelector fails for appearance proxy

前端 未结 1 1500
攒了一身酷
攒了一身酷 2021-01-03 21:33

I’m trying to detect an iOS 6-specific appearance method, by running respondsToSelector on the [UIBarButtonItem appearance]. However, it always ret

相关标签:
1条回答
  • 2021-01-03 22:37

    Don't check the appearance proxy. You can never rely on that, since it's a proxy. Instead, directly check the item that has the new method, in this case, the UIBarButtonItem:

    BOOL hasNewMethod = [UIBarButtonItem instancesRespondToSelector:@selector(setBackgroundImage:forState:style:barMetrics:)];
    if( hasNewMethod )
      NSLog(@"Running iOS 6 with new method");
    else
      NSLog(@"Current OS doesn't support method...");
    
    0 讨论(0)
提交回复
热议问题