调用 deselectRowAtIndexPath 后,AccessoryDe​​tailDisclosureButton 未取消选择 [英] AccessoryDetailDisclosureButton not deselecting after I call deselectRowAtIndexPath

查看:32
本文介绍了调用 deselectRowAtIndexPath 后,AccessoryDe​​tailDisclosureButton 未取消选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 tableview 中,我有许多行具有显示详细信息按钮附件类型,当按下行或附件时,一个新视图被推送到导航控制器.我在 didSelectRowAtIndexPath 函数的末尾调用了 deselectRowAtIndexPath.

In my tableview I have number of rows that have disclosure detail button accessory type, and when pressing the row or the accessory, a new view is pushed to a navigation controller. I call the deselectRowAtIndexPath at the end of the didSelectRowAtIndexPath function.

如果我按下附件按钮,我会转到一个新视图,但是当我回到这个视图(弹出)时它会保持突出显示.该行按预期取消选择,但不是这样.关于如何取消突出显示"它的任何想法?

If I press the accessory button, I go to a new view, but it remains highlighted when I come back to this view (pop). The row is deselected as expected but not this. Any thoughts on how to 'unhighlight' it?

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ...
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    }
    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
     [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
     [self tableView:tableView didSelectRowAtIndexPath:indexPath];
    }

推荐答案

只需从您的目录中删除

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;

方法声明

[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];

由于您的表格已经允许选择,并且您在

Since your table already allows selection, and you are correctly deselecting it in

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

大功告成,因为当按下显示按钮选择该行时将突出显示该行,并在执行 tableView:didSelectRowAtIndexPath: 时取消选择.

you are done, because the row will be highlighted when selected pressing the disclosure button, and deselected when tableView:didSelectRowAtIndexPath: is executed.

这篇关于调用 deselectRowAtIndexPath 后,AccessoryDe​​tailDisclosureButton 未取消选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆