<i id='AkhD7'><tr id='AkhD7'><dt id='AkhD7'><q id='AkhD7'><span id='AkhD7'><b id='AkhD7'><form id='AkhD7'><ins id='AkhD7'></ins><ul id='AkhD7'></ul><sub id='AkhD7'></sub></form><legend id='AkhD7'></legend><bdo id='AkhD7'><pre id='AkhD7'><center id='AkhD7'></center></pre></bdo></b><th id='AkhD7'></th></span></q></dt></tr></i><div id='AkhD7'><tfoot id='AkhD7'></tfoot><dl id='AkhD7'><fieldset id='AkhD7'></fieldset></dl></div>
      <legend id='AkhD7'><style id='AkhD7'><dir id='AkhD7'><q id='AkhD7'></q></dir></style></legend>
      <tfoot id='AkhD7'></tfoot>
          <bdo id='AkhD7'></bdo><ul id='AkhD7'></ul>
      1. <small id='AkhD7'></small><noframes id='AkhD7'>

        respondsToSelector 外观代理失败

        时间:2023-09-02

        <small id='lH34B'></small><noframes id='lH34B'>

          <bdo id='lH34B'></bdo><ul id='lH34B'></ul>
                <tbody id='lH34B'></tbody>
            • <tfoot id='lH34B'></tfoot>
              <i id='lH34B'><tr id='lH34B'><dt id='lH34B'><q id='lH34B'><span id='lH34B'><b id='lH34B'><form id='lH34B'><ins id='lH34B'></ins><ul id='lH34B'></ul><sub id='lH34B'></sub></form><legend id='lH34B'></legend><bdo id='lH34B'><pre id='lH34B'><center id='lH34B'></center></pre></bdo></b><th id='lH34B'></th></span></q></dt></tr></i><div id='lH34B'><tfoot id='lH34B'></tfoot><dl id='lH34B'><fieldset id='lH34B'></fieldset></dl></div>
              <legend id='lH34B'><style id='lH34B'><dir id='lH34B'><q id='lH34B'></q></dir></style></legend>

                • 本文介绍了respondsToSelector 外观代理失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试通过在 [UIBarButtonItem 外观] 上运行 respondsToSelector 来检测 iOS 6 特定的外观方法.但是,无论我指定什么选择器,它总是为我返回 NO:

                  I’m trying to detect an iOS 6-specific appearance method, by running respondsToSelector on the [UIBarButtonItem appearance]. However, it always returns NO for me, whatever selector I specify:

                  // Should show NOPE in iOS 5, YEP in iOS 6. Shows NOPE always
                  NSLog(@"%@", [[UIBarButtonItem appearance] respondsToSelector:@selector(setBackgroundImage:forState:style:barMetrics:)] ? @"YEP" : @"NOPE"); 
                  
                  // Should show YEP in both iOS 5 and iOS 6. Shows NOPE always
                  NSLog(@"%@", [[UIBarButtonItem appearance] respondsToSelector:@selector(setBackgroundImage:forState:barMetrics:)] ? @"YEP" : @"NOPE"); 
                  

                  实际上,在它们各自的 iOS 版本上使用这些方法都可以正常工作,但我似乎无法检测到哪一个对我可用.那么我该如何正确地做到这一点呢?

                  Actually using those methods works fine on their respective versions of iOS, but I can’t seem to detect which one is available to me. So how do I properly do that?

                  推荐答案

                  不要检查外观代理.你永远不能依赖它,因为它是一个代理.相反,直接检查具有新方法的项目,在这种情况下,UIBarButtonItem:

                  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...");
                  

                  这篇关于respondsToSelector 外观代理失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:需要通过 iOS SDK 在我的服务器上使用 JSON 对用户 下一篇:iOS5:在模态 UIViewController 中播放 Youtube 视频时 U

                  相关文章

                  最新文章

                  <tfoot id='KKblD'></tfoot>

                • <i id='KKblD'><tr id='KKblD'><dt id='KKblD'><q id='KKblD'><span id='KKblD'><b id='KKblD'><form id='KKblD'><ins id='KKblD'></ins><ul id='KKblD'></ul><sub id='KKblD'></sub></form><legend id='KKblD'></legend><bdo id='KKblD'><pre id='KKblD'><center id='KKblD'></center></pre></bdo></b><th id='KKblD'></th></span></q></dt></tr></i><div id='KKblD'><tfoot id='KKblD'></tfoot><dl id='KKblD'><fieldset id='KKblD'></fieldset></dl></div>
                • <small id='KKblD'></small><noframes id='KKblD'>

                    <bdo id='KKblD'></bdo><ul id='KKblD'></ul>

                    <legend id='KKblD'><style id='KKblD'><dir id='KKblD'><q id='KKblD'></q></dir></style></legend>