• <bdo id='fNp9P'></bdo><ul id='fNp9P'></ul>
    1. <small id='fNp9P'></small><noframes id='fNp9P'>

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

        <tfoot id='fNp9P'></tfoot>
        <legend id='fNp9P'><style id='fNp9P'><dir id='fNp9P'><q id='fNp9P'></q></dir></style></legend>

        将参数传递给@selector 方法

        时间:2023-07-08
          <bdo id='KdpBf'></bdo><ul id='KdpBf'></ul>

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

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

                  <tbody id='KdpBf'></tbody>

                1. <legend id='KdpBf'><style id='KdpBf'><dir id='KdpBf'><q id='KdpBf'></q></dir></style></legend>

                  本文介绍了将参数传递给@selector 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在表格视图中添加了一个 UIButton.现在,当我单击特定按钮时,我需要获取与该行对应的对象的详细信息.

                  I have added a UIButton in a table view. Now when I click a particular button, I need to get the details of the object corresponding to that row.

                  [button addTarget:self 
                             action:@selector(invite:contactmail:) 
                   forControlEvents:UIControlEventTouchUpInside];  
                  

                  我在按钮上使用了这种方法;如何将参数传递给此选择器方法?或者有没有其他方法可以在单击此按钮时将参数传递给此方法?

                  I have used this method for the button; how can I pass arguments to this selector method? Or is there any other way to pass arguments to this method when this button is clicked?

                  推荐答案

                  作为操作添加到 UIControl 的方法可以有 3 个不同的签名

                  methods you add as actions to a UIControl can have 3 different signatures

                  - (void)action
                  - (void)action:(id)sender
                  - (void)action:(id)sender event:(UIEvent *)event
                  

                  你不能传递你自己的对象.通常可以在发送者(您的按钮)对象的帮助下获取您尝试传递的任何对象.

                  you can't pass your own object. Often it is possible to get whatever object you are trying to pass with the help of the sender (your button) object.

                  如果您在 tableviewcell 中有一个按钮,您可以使用类似的方法来获取单元格的索引路径.

                  If you have a button in a tableviewcell you could use something like this to get the indexpath of the cell.

                  - (IBAction)buttonAction:(id)sender {
                      UIButton *button = (UIButton *)sender;
                      CGPoint buttonOriginInTableView = [button convertPoint:CGPointZero toView:tableView];
                      NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:buttonOriginInTableView];
                  
                      // do something
                  }
                  

                  并且通过 indexPath 你可以得到你需要的对象.

                  and with the indexPath you can get the object you need.

                  这篇关于将参数传递给@selector 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIButton 的选定状态在 iOS7 中不起作用 下一篇:Retina 显示器 VS 正常显示器色差

                  相关文章

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

                  2. <legend id='XcKkZ'><style id='XcKkZ'><dir id='XcKkZ'><q id='XcKkZ'></q></dir></style></legend>
                  3. <tfoot id='XcKkZ'></tfoot>

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

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