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

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

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

      1. Button离开高亮状态时调用方法

        Call method when Button leaves Highlighted State(Button离开高亮状态时调用方法)

            <tbody id='34S97'></tbody>

                <small id='34S97'></small><noframes id='34S97'>

                <tfoot id='34S97'></tfoot>
                  <bdo id='34S97'></bdo><ul id='34S97'></ul>

                  <legend id='34S97'><style id='34S97'><dir id='34S97'><q id='34S97'></q></dir></style></legend>
                  <i id='34S97'><tr id='34S97'><dt id='34S97'><q id='34S97'><span id='34S97'><b id='34S97'><form id='34S97'><ins id='34S97'></ins><ul id='34S97'></ul><sub id='34S97'></sub></form><legend id='34S97'></legend><bdo id='34S97'><pre id='34S97'><center id='34S97'></center></pre></bdo></b><th id='34S97'></th></span></q></dt></tr></i><div id='34S97'><tfoot id='34S97'></tfoot><dl id='34S97'><fieldset id='34S97'></fieldset></dl></div>
                  本文介绍了Button离开高亮状态时调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在按钮突出显示时执行一个操作,并在它离开突出显示状态时执行另一个操作.有什么建议吗?

                  I want to perform a action when a button is highlighted and perform another action when it leaves the highlighted state. Any advice?

                  推荐答案

                  你可以使用KVO

                  [button addObserver:self forKeyPath:@"highlighted" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
                  

                  然后

                  - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
                  {
                      if ([@"highlighted" isEqualToString:keyPath]) {
                  
                          NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey];
                          NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey];
                  
                          if (old && [new isEqualToNumber:old]) {
                              NSLog(@"Highlight state has not changed");
                          } else {
                              NSLog(@"Highlight state has changed to %d", [object isHighlighted]);
                          }
                      }
                  }
                  

                  您只真正关心更改,并且每次状态更改时都会调用它,例如如果您移动选择,然后用手指向下拖动到按钮外

                  You only really care about the changes and this will be called every time the state changes e.g. if you move select and then with your finger still down drag outside of the button

                  这篇关于Button离开高亮状态时调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UIButton title text color(UIButton 标题文本颜色)
                  Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                  Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                  How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                  Minimum sensible button size on iPhone(iPhone 上的最小合理按钮大小)
                  iPhone UIButton - image position(iPhone UIButton - 图像位置)

                    <tbody id='QAYP3'></tbody>

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

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

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