我有一个基于 UITabBarController 的应用程序。我从应用程序委托实例化它并在标签栏控制器中添加一个自定义按钮。单击该按钮时,我想以模态方式呈现另一个视图,但我似乎不知道该怎么做。添加按钮我基本上是这样做的
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
[self.tabBarController.view addSubview:button];
[button addTarget:self action:@selector(showModalViewController:) forControlEvents:UIControlEventTouchUpInside];
而且在应用程序委托中我有一个方法
- (void) showModalViewController {
DummyViewController *addController = [[DummyViewController alloc]
initWithNibName:@"DummyViewController" bundle:nil];
//addController.delegate = self;
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
// Create the navigation controller and present it modally.
[self.tabBarController.selectedViewController presentModalViewController:addController animated:YES];
// The navigation controller is now owned by the current view controller
}
我不断收到无法识别的选择器