0

ナビゲーションバーに次のようなボタンを追加しました。

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(methodtocall:)];          

self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];

ただし、これを押すと、InvalidArgumentExceptionが発生します。これはまったく新しいナビゲーションプロジェクトです。なぜ私がこの振る舞いをするのか誰か知っていますか?

4

1 に答える 1

1

次のようにアクション メソッドを定義する必要があります。

-(void) methodtocall:(UIBarButtonItem *) sender {
   //do stuff...
}

InvalidArgumentを受け取るメソッドを定義していないため、おそらくエラーが発生していますUIBarButtonItem

于 2010-06-15T14:38:57.313 に答える