【发布时间】:2012-12-23 07:07:05
【问题描述】:
通常我典型的 didselectrowatindexpath 是这样的:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
BGUIBusinessCellForDisplay * cellBiz = (BGUIBusinessCellForDisplay *) cell;
[BGDetailBusinessViewController detailButtonPressed:cellBiz.biz withNavController:self.navigationController];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
所以如果一行是selectec,打开一个新窗口或其他东西。然后快速取消选择该行。不取消选择行意味着当我们取回之前选择的行时,之前选择的行仍然存在。
但是,如果我查看我过去的代码,我发现该行已成功取消选择,即使我根本没有调用取消选择
我在各处放置了一个陷阱来跟踪取消选择该行的位置和时间:
-(void)viewDidAppear:(BOOL)animated
{
...
PO(self.tableView.indexPathForSelectedRow); //always show null here
while(false);
}
viewDidAppear 显示,在我从详细信息返回后,self.tablevView.indexPathForSelectedRow 已经为空。所以该行已经被取消选择,但是何时何地?
我在明显的地方设置了更多的陷阱
-(void)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
while (false);//breakpoint here never called
}
-(void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *) indexPath
{
while (false); //breakpoint here never called
}
这些都没有被调用过。
我放弃了。
现在还不算大,但这让我很困惑
这是完整的 didSelectRowForIndexPath,因此您可以验证那里没有取消选择命令
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell isKindOfClass:[BGUIBusinessCellForDisplay class]])
{
BGUIBusinessCellForDisplay * cellBiz = (BGUIBusinessCellForDisplay *) cell;
[BGDetailBusinessViewController detailButtonPressed:cellBiz.biz withNavController:self.navigationController];
}
else if ([cell isKindOfClass:[BGAddMoreBusiness class]])
{
BGBusinessEditViewController * editBusiness = [[BGBusinessEditViewController alloc]init];
[self.navigationController SafelyPushController:editBusiness];
}
PO(self.tableView.indexPathForSelectedRow); //not null here
}
【问题讨论】:
标签: php objective-c noop