gpt4 book ai didi

ios - TableView :didSelectRowAtIndexPath/popViewControllerAnimated do not work

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:05:21 24 4
gpt4 key购买 nike

当我使用

tableView:didSelectRowAtIndexPath / popViewControllerAnimated

它不起作用。我将 View Controller 推到另一个 View ,但是当我选择一行时,它以灰色突出显示,而不是立即弹出到原始 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com