通常、私の典型的な 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 の場合は、新しいウィンドウか何かを開きます。次に、行の選択をすばやく解除します。行の選択を解除しないということは、以前に選択した行がまだそこにあることを意味します。
ただし、過去のコードを確認すると、deselect をまったく呼び出さなかったにもかかわらず、行が正常に選択解除されていることがわかりました
行がいつどこで選択解除されたかを追跡するために、どこにでもトラップを配置します。
-(void)viewDidAppear:(BOOL)animated
{
...
PO(self.tableView.indexPathForSelectedRow); //always show null here
while(false);
}
たとえば、詳細から戻った後、self.tablevView.indexPathForSelectedRow は既に null です。行はすでに選択解除されていますが、いつ、どこで?
明らかな場所にトラップを追加します
-(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
}