为什么没有调用-didDeselectRowAtIndexPath? [英] Why is -didDeselectRowAtIndexPath not being called?

查看:720
本文介绍了为什么没有调用-didDeselectRowAtIndexPath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新项目(Xcode 4,Master-Detail应用程序),看看我做错了什么,但我仍然遇到同样的问题。当用户取消选择一个单元格时,我想调用 -reloadData ,所以这是我的代码:

I created a fresh project (Xcode 4, Master-Detail application) just to see if I'm doing something wrong, but I still have the same problem. I want to call -reloadData when the user deselects a cell, so this is my code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __PRETTY_FUNCTION__);
    [tableView reloadData];
}

-(NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __PRETTY_FUNCTION__);
    return indexPath;
}

问题是 didDeselectRowAtIndexPath willDeselectRowAtIndexPath 。这是预期的行为吗? tableView的文档:didDeselectRowAtIndexPath: state

The problem is that didDeselectRowAtIndexPath and willDeselectRowAtIndexPath don't seem to be called. Is this the expected behavior? The docs for tableView:didDeselectRowAtIndexPath: state


告诉委托指定的行现在取消选择。

Tells the delegate that the specified row is now deselected.

所以我猜它应该按照我的想法运作。

so I guess that it should work as I thought.

推荐答案

tableView:willDeselectRowAtIndexPath: 也说


仅当
用户尝试选择其他行时,如果存在选择,则仅调用此方法。代理将以此方法
发送给先前选定的行。您可以使用
UITableViewCellSelectionStyleNone 来禁用触摸时
单元格高亮显示的外观。

This method is only called if there is an existing selection when the user tries to select a different row. The delegate is sent this method for the previously selected row. You can use UITableViewCellSelectionStyleNone to disable the appearance of the cell highlight on touch-down.

当我使用 UITableViewCellSelectionStyleNone 时,它不起作用。

It not worked for we when I used UITableViewCellSelectionStyleNone.

这篇关于为什么没有调用-didDeselectRowAtIndexPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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