当我使用时
tableView:didSelectRowAtIndexPath / popViewControllerAnimated
它不起作用。我通过另一个 View 插入 View Controller ,但是当我选择一行时,它会以灰色突出显示,而不是立即弹出到原始 View Controller 。但是当我点击另一行时,它会选择我点击的第一行,然后返回到原始 View Controller 。
这是代码:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
NSArray *allTypes = [[ItemStore sharedStore] allTypes];
NSManagedObject *raum = allTypes[indexPath.row];
self.an.leben = raum;
[self.navigationController popViewControllerAnimated:YES];
}
有什么想法吗?
最佳答案
将 didDeselectRowAtIndexPath
替换为 didSelectRowAtIndexPath
。
您编写的委托(delegate)方法是didDeselectRowAtIndexPath
,而不是didSelectRowAtIndexPath
。
根据苹果的说法,tableView:didDeselectRowAtIndexPath:
告诉代理指定的行现在已取消选择。
和
tableView:didSelectRowAtIndexPath: 告诉代理指定的行现在已选择。
因此,发生的情况是,当您单击一行时,它会被选中并变成灰色,然后当您单击同一行或任何其他行时,前一行会被取消选择,因为一次只选择一行,并且因此调用此方法来打开带有上一个点击行的下一个 View Controller 。
关于ios - TableView :didSelectRowAtIndexPath/popViewControllerAnimated do not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23592178/