gpt4 book ai didi

ios - 无法在 segue 期间传递唯一数据

转载 作者:行者123 更新时间:2023-11-29 12:55:54 24 4
gpt4 key购买 nike

我无法从选定的表格单元格中获取唯一数据。我点击的每个单元格似乎都传递相同的数据。关于我在这里做错了什么有什么建议吗?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

if ([segue.identifier isEqualToString:@"MallToVendor"]) {
MingieAdvertisementIndividualViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
destViewController.mallName = [[advertisements objectAtIndex:indexPath.row] name];
}
}

最佳答案

不使用 indexPathForSelectedRow,而是将 didSelectRowAtIndexPath 方法中选定的 indexpath.row 保存在整数变量中并在 prepareForSegue 中使用它。

如果您使用 indexPathForSelectedRow,它将始终返回第一行的 indexpath

希望这对您有所帮助!

关于ios - 无法在 segue 期间传递唯一数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21112622/

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