gpt4 book ai didi

objective-c - Segued 时如何获取我的 UITableViewController 实例?

转载 作者:行者123 更新时间:2023-11-29 13:24:00 25 4
gpt4 key购买 nike

我有一个问题。我有一个类正在为 UITableView 实现 DatasourceDelegate

我的 TableViewController 是从我已设置到工具栏中的 UIBarButton 的弹出窗口中分离出来的。 (此工具栏是 UINavigationController 的一部分)。

我现在的问题是我不知道如何将我的 datasource 对象传递给我的 UITableviewController。所以问题是。我怎样才能从我的导航 Controller 的工具栏中获取 UITableviewController 的实例?

最佳答案

在之前viewController的prepareForSeque方法中可以访问到segue.destinationViewController。然后将其转换为您需要的 (UITableViewController *)segue.destinationViewController 以便您可以访问自定义方法来设置数据对象或设置数据委托(delegate)

有点像

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SomeClasViewController *vc = [segue destinationViewController];
[vc setDataObject:SomeDataObject];
}

关于objective-c - Segued 时如何获取我的 UITableViewController 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13634091/

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