当 navigationController 弹出视图时取消选择选定的单元格是什么? [英] What deselect selected cell when navigationController pops a view?

查看:21
本文介绍了当 navigationController 弹出视图时取消选择选定的单元格是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

苹果提供的默认导航控制器模板,它有一个导航控制器和一个表.

The default NavigationController template offered by apple, it has one navigationController and a table.

如果你选择一个单元格,一个新的视图将被推送到导航控制器中,如果你弹出视图,选定的单元格将自动取消突出显示.

And if you select a cell, a new view will be pushed into navigationController and if you pop the view, the selected cell will be de-hightlighted automatically.

但是表格如何知道何时取消突出显示以及它如何知道选择了哪个单元格??

But how does table know when to de-hightlight it and how does it know which cell is selected??

还是只是重新加载所有数据?

or does it just re-load all data again?

推荐答案

table 如何知道何时去高亮显示它

how does table know when to de-hightlight it

您可以在选择处理程序中取消选择您的单元格:

You can deselect your cell right in selection handler:

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

或在控制器的 -viewWillAppear: 方法中重置选择

or reset selection in controller's -viewWillAppear: method

它如何知道选择了哪个单元格?

and how does it know which cell is selected?

UITableView 有以下方法来获取选中的行 indexPath:

UITableView has the following method to get selected row indexPath:

- (NSIndexPath *)indexPathForSelectedRow

这篇关于当 navigationController 弹出视图时取消选择选定的单元格是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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