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

标签 ios uiviewcontroller

新手 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/

相关文章:

ios - 我需要设计洒水图,但不使用 CorePlot。

iphone - 在 plist 中获取图像路径

iphone - glVertexPointer - 绘制不需要的线条

iPhone重新加载表数据

ios5如何通过prepareForSegue : a UIImageView

iphone - View Controller 包含与直接 View 操作

iOS 应用程序 : Firebase Dynamic Links are not working with latest Pod file

ios - UILabel 的 TextContainer 上的排除路径

objective-c - 添加的按钮未显示在 UINavigationController 上

ios - 来自 UIView 的文件所有者的 IBAction 在 UIViewController 中不起作用