gpt4 book ai didi

objective-c - 如何通过多个详细 View Controller 保留indexPath值?

转载 作者:行者123 更新时间:2023-11-29 05:01:30 25 4
gpt4 key购买 nike

如何通过多个详细信息 View Controller 保留 RootViewController 中的 indexPath 值?

我有一个分割 View Controller 和多个带有工具栏的详细 View 。

我希望能够在调用检索indexPath.row值并使用indexPath.row+1的方法时更改详细 View 。

所以基本上,我希望每个 View Controller 都有一个 selectedRow = indexPath 分配。目前我收到了一个未声明使用错误的indexPath。

最佳答案

有很多方法可以管理这个问题。

每次选择更改时,每个详细 View Controller 都可以将其选择状态写入某个公共(public)位置。每当 on 获取 viewWillAppear 时:它都会设置其选择。

如果您使用分段 View Controller ,则在它调用的操作中,它可以从当前详细 View Controller 中获取选择,更改 Controller ,然后在新 Controller 中设置选择。

或者……无限


熟悉 UITableViewController 的文档- indexPathForSelectedRow 是您获取所选索引的方式,selectRowAtIndexPath:animated:scrollPosition: 是您在表格上设置它的方式。请注意,发送无效的 indexPath 将导致异常。如果表的大小不同,这可能会出现问题。用 @try 换行或在调用之前检查

关于objective-c - 如何通过多个详细 View Controller 保留indexPath值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6808479/

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