1
我有一個模式的視圖控制器,從我的主視圖呈現,我在視圖的右上角添加了一個「完成」按鈕(navigationcontroller)。但是,我無法讓選擇器調用正確的方法。下面是我使用的設置模式視圖代碼:ModalViewController消除選擇器的視圖
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變量的方法。我怎樣才能讓選擇器調用正確的方法?
感謝
是的,這就是所有它只是需要調用沒有冒號。謝謝。 – danielbeard
Typo ===> IBarButtonItem – DAS
修復@DAS謝謝。 –