gpt4 book ai didi

ios - 想要在用户单击完成后调用 presentingViewController 中的方法

转载 作者:可可西里 更新时间:2023-11-01 05:38:14 26 4
gpt4 key购买 nike

新手 iOS 开发人员在这里采用了 iOS 应用程序。

我有一个 iOS 应用程序的设置部分,当用户单击“完成”时,我想要模态视图 Controller (它当前使用的)并且我想在 presentingViewController 中调用一个名为 updateMainUI 的函数。

这是我调用的方法:

- (void)done:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil]; // works
[[self presentingViewController updateMainUI]; //doesn't work

但是我得到以下错误:

No visible @interface for 'UIViewController' declares the selector 'updateMainUI'

但是我已经在呈现 Controller 中声明了这一点

@interface LocationsViewController : UITableViewController <CLLocationManagerDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
-(void)updateMainUI;

但奇怪的是,当呈现 Controller 是 UITableViewController 时,错误应该是关于 UIViewController 的。

关于如何让 updateMainUI 工作的任何想法?我做错了什么?

谢谢

编辑#1这就是我创建它的方式 - 知道如何获得对 *nearbyViewController 的引用吗?

UIViewController *nearbyViewController = [[LocationsViewController alloc] initWithNearbyLocations];
UINavigationController *nearbyNavigationController = [[UINavigationController alloc] initWithRootViewController:nearbyViewController];
...
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nearbyNavigationController, browseNavigationController, eventsNavigationController, nil];

最佳答案

关闭 self 后,您应该期望 self.presentingViewController 变为 nil。尝试在关闭之前调用 updateMainUI

关于ios - 想要在用户单击完成后调用 presentingViewController 中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10560636/

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