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

    1. <tfoot id='kQopl'></tfoot>

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

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

        代表们,我无法理解他们

        Delegates, can#39;t get my head around them(代表们,我无法理解他们)
        • <legend id='vOCBb'><style id='vOCBb'><dir id='vOCBb'><q id='vOCBb'></q></dir></style></legend>

              <tbody id='vOCBb'></tbody>
            <tfoot id='vOCBb'></tfoot>
            • <bdo id='vOCBb'></bdo><ul id='vOCBb'></ul>

              1. <small id='vOCBb'></small><noframes id='vOCBb'>

                <i id='vOCBb'><tr id='vOCBb'><dt id='vOCBb'><q id='vOCBb'><span id='vOCBb'><b id='vOCBb'><form id='vOCBb'><ins id='vOCBb'></ins><ul id='vOCBb'></ul><sub id='vOCBb'></sub></form><legend id='vOCBb'></legend><bdo id='vOCBb'><pre id='vOCBb'><center id='vOCBb'></center></pre></bdo></b><th id='vOCBb'></th></span></q></dt></tr></i><div id='vOCBb'><tfoot id='vOCBb'></tfoot><dl id='vOCBb'><fieldset id='vOCBb'></fieldset></dl></div>
                  本文介绍了代表们,我无法理解他们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您好,我正在寻找有关代表的有用资源.我了解代表坐在后台并在某些事情发生时接收消息 - 例如.选择表格单元格,或检索来自网络连接的数据.

                  Hey, I'm looking for useful resources about Delegates. I understand that the delegate sits in the background and receives messages when certain things happen - e.g. a table cell is selected, or data from a connection over the web is retrieved.

                  我特别想知道的是如何将委托与多个对象一起使用.据我所知,为对象(例如表格单元格)指定相同的委托会导致同时为两个单元格调用相同的事件.有什么相当于为特定对象实例化委托的方法吗?

                  What I'd like to know in particular is how to use delegates with multiple objects. As far as I know, specifying the same delegate for an object (e.g. table cell) would cause the same events to be called for both the cells at the same time. Is there anything equivalent to instantiating a delegate for a particular object?

                  提前致谢!

                  推荐答案

                  在 Cocoa 中,对象几乎总是在调用委托方法时标识自己.例如,UITableView 在调用时将自己作为委托消息的第一个参数传递:

                  In Cocoa, objects almost always identify themselves when calling a delegate method. For example, UITableView passes itself as the first parameter of the delegate message when calling it:

                  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
                  

                  如果您希望同一个委托处理多个 UITableView,那么您只需要对传递给方法的 tableView 对象设置一些条件:

                  If you wanted the same delegate to handle multiple UITableViews, then you just need a some conditional on the tableView object passed to the method:

                  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
                  {
                      if (tableView == self.myFirstTableView) {
                          // do stuff
                      } else if (tableView == self.mySecondtableView) {
                          // do other stuff
                      }
                  }
                  

                  }

                  如果您不想直接比较对象指针,您可以随时使用 tag 属性来唯一标识您的视图.

                  If you don't want to compare the object pointers directly, you can always use the tag property to uniquely identify your views.

                  这篇关于代表们,我无法理解他们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to pass a #39;tap#39; to UIButton that is underneath UIView with UISwipeGestureRecognizer?(如何使用 UISwipeGestureRecognizer 将“点击传递给 UIView 下方的 UIButton?)
                  Objective c - Best practice to handle a button touch event for a button of a custom UITableViewCell(Objective c - 为自定义 UITableViewCell 的按钮处理按钮触摸事件的最佳实践)
                  UIButton targets not working if a UIView is added as a subview(如果将 UIView 添加为子视图,则 UIButton 目标不起作用)
                  Tint UIButton#39;s image from interface builder with UIImageRenderingModeAlwaysTemplate(使用 UIImageRenderingModeAlwaysTemplate 从界面生成器中为 UIButton 的图像着色)
                  How can i increase the button width dynamically depends on the text size in iphone?(如何根据 iphone 中的文本大小动态增加按钮宽度?)
                  What#39;s the difference between UIControlStateHighlighted and UIControlStateSelected?(UIControlStateHighlighted 和 UIControlStateSelected 有什么区别?)

                    • <tfoot id='vM3UJ'></tfoot>
                      • <bdo id='vM3UJ'></bdo><ul id='vM3UJ'></ul>
                              <tbody id='vM3UJ'></tbody>

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

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

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