想要在用户点击完成后调用showsViewController中的方法 [英] want to call a method in the presentingViewController after user has clicked done
问题描述
Noobie iOS开发人员在这里采用了iOS应用程序。
Noobie iOS developer with an adopted iOS app here.
我有一个iOS应用程序的设置部分,当用户点击完成时,我想要模态视图控制器(它目前正在做)我想在presentViewController中调用一个名为updateMainUI的函数。
I have a settings piece of an iOS app and when the user clicks done, I want the modal view controller (which it currently does) and I want to call a function called updateMainUI in the presentingViewController.
这是我打电话的方法:
- (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'
但我已在演示控制器中声明了这一点
But I have declared this in the presenting controller
@interface LocationsViewController : UITableViewController <CLLocationManagerDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
-(void)updateMainUI;
但是当呈现控制器是UITableViewController时,错误应该是关于UIViewController的奇怪。
But it's odd that the error should be about UIViewController when the presenting controller is a UITableViewController.
有关如何使updateMainUI正常工作的任何想法?我做错了什么?
Any ideas on how to get the updateMainUI working? And what I'm doing wrong?
thx
编辑#1
这就是我创建这个的方法 - 任何想法如何引用* nearbyViewController?
edit #1 This is how I'm creating this - any idea how to get a refernce to the *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
。
After dismissing ones self
, you should expect self.presentingViewController
to become nil
. Try calling updateMainUI
just before dismissing.
这篇关于想要在用户点击完成后调用showsViewController中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!