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

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

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

        • <bdo id='ExHqx'></bdo><ul id='ExHqx'></ul>

        UITableViewCell 自定义附件 - 获取附件的行

        时间:2023-10-03

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

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

            <legend id='jNPJJ'><style id='jNPJJ'><dir id='jNPJJ'><q id='jNPJJ'></q></dir></style></legend>
              <bdo id='jNPJJ'></bdo><ul id='jNPJJ'></ul>
                <tbody id='jNPJJ'></tbody>
            • <tfoot id='jNPJJ'></tfoot>
                1. 本文介绍了UITableViewCell 自定义附件 - 获取附件的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个很大的问题.我正在尝试在 UITableView 中的每个 UITableViewCell 上创建一个收藏按钮.这很好用,我目前在按下时执行了一个动作和选择器.

                  I have a pretty big issue. I am trying to create a favorite-button on every UITableViewCell in a UITableView. That works very good, and I currently have an action and selector performed when pressed.

                  accessory = [UIButton buttonWithType:UIButtonTypeCustom];
                  [accessory setImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal];
                  accessory.frame = CGRectMake(0, 0, 15, 15);
                  accessory.userInteractionEnabled = YES;
                  [accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchUpInside];
                  cell.accessoryView = accessory;
                  

                  和选择器:

                  - (void) didTapStar {
                      UITableViewCell *newCell = [tableView cellForRowAtIndexPath:/* indexPath? */];
                  
                      accessory = [UIButton buttonWithType:UIButtonTypeCustom];
                      [accessory setImage:[UIImage imageNamed:@"stared.png"] forState:UIControlStateNormal];
                      accessory.frame = CGRectMake(0, 0, 26, 26);
                      accessory.userInteractionEnabled = YES;
                      [accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchDown];
                      newCell.accessoryView = accessory;
                  }
                  

                  现在,问题来了:我想知道按下的附件属于哪一行.我该怎么做?

                  Now, here's the problem: I want to know what row the accessory that was pressed belongs to. How can I do this?

                  谢谢你:)

                  推荐答案

                  我会使用以下代码:

                  - (void)didTapStar:(id)sender {
                    NSIndexPath *indexPath = [tableView indexPathForCell:(UITableViewCell *)[sender superview]];
                  }
                  

                  这篇关于UITableViewCell 自定义附件 - 获取附件的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:NSDateFormatter 的 init 方法已弃用? 下一篇:数学表达式评估 - 非常快 - 使用 Objective-C

                  相关文章

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

                      <bdo id='b9rrQ'></bdo><ul id='b9rrQ'></ul>
                    <tfoot id='b9rrQ'></tfoot>
                    1. <small id='b9rrQ'></small><noframes id='b9rrQ'>