1

私はメインビューから表示されるモーダルビューコントローラを持っていますが、ビュー(navigationcontroller)の右上に「完了」ボタンを追加しています。しかし、セレクタに正しいメソッドを呼び出させることはできません。その後、私のgraphViewクラスで、私は方法を持っている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]; 

-(void) dismissView { 
    [self dismissModalViewControllerAnimated: YES]; 
} 

コードを実行している場合しかし、私は認識されていないセレクタを取得ここで私は、モーダルビューを設定するために使用していたコードです。セレクタがUINavigationController変数でメソッドを呼び出そうとしています。セレクタに正しいメソッドを呼び出させるにはどうすればよいですか?セレクタを呼び出すとき

おかげ

答えて

2

あなたは間違ってをした:dismissViewが

-(void) dismissView; 

として定義されている場合

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] 
          initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
          target:graphView 
          action:@selector(dismissView:)]; 

あなたは

-(void) dismissView:(id)sender; 

としてdismissViewを定義する必要がありますかc結腸のないものすべて

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] 
          initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
          target:graphView 
          action:@selector(dismissView)]; 
+1

結局のところ、結腸なしで呼び出すだけでいいです。ありがとう。 – danielbeard

+0

Typo ===> IBarButtonItem – DAS

+0

@DASに感謝しました。 –

関連する問題