问题描述
我创建了一个新项目(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 $ c $似乎没有调用c>和
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
所以我猜它应该按照我的想法运作。
so I guess that it should work as I thought.
推荐答案
也说
当我使用 UITableViewCellSelectionStyleNone
时,它不起作用。
It not worked for we when I used UITableViewCellSelectionStyleNone
.
这篇关于为什么没有调用-didDeselectRowAtIndexPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!