【发布时间】:2012-02-18 09:28:54
【问题描述】:
我有一个从我的主视图显示的模态视图控制器,我在视图的右上角添加了一个“完成”按钮(导航控制器)。但是,我无法让选择器调用正确的方法。这是我用来设置模态视图的代码:
GraphView *graphView = [[[GraphView alloc] initWithNibName:@"GraphView" bundle:nil] autorelease];
//Set values in the graphView view
[graphView setInterest:interestRateSlider.value / 10];
[graphView setMonths: (loanTermSlider.value / 2.0) * 12]; // Years * 12 = months
[graphView setPrincipal:[principal intValue]];
//show the graph view as a modal navigation controller view
UINavigationController *graphNavigationController = [[UINavigationController alloc] initWithRootViewController:graphView];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:graphView
action:@selector(dismissView:)];
graphView.navigationItem.rightBarButtonItem = doneButton;
[graphNavigationController.navigationItem.rightBarButtonItem setTitle:@"Done"];
[graphView.navigationItem setTitle:@"Graph"];
[self presentModalViewController:graphNavigationController animated:YES];
[graphNavigationController release];
[doneButton release];
然后在我的 graphView 类中我有方法:
-(void) dismissView {
[self dismissModalViewControllerAnimated: YES];
}
但是,在运行代码时,我得到了无法识别的选择器。选择器正在尝试调用 UINavigationController 变量上的方法。如何让选择器调用正确的方法?
谢谢
【问题讨论】:
标签: iphone objective-c uinavigationcontroller modalviewcontroller