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