MainWindow.xib ファイルのバー ボタンから ModalViewController を表示したいと思います。どうすればいいですか?私が使用しようとしている基本的なコードは次のとおりです。
-(IBAction)add {
myCustomViewController *add = [[myCustomViewController alloc] initWithNibName:@"myCustomViewController" bundle:nil];
[self presentModalViewController:add animated:YES];
[add release];
}
しかし、どこに置くのですか?
編集:私はそれを理解しました、私のナビゲーションコントローラーで、次のコードをviewDidLoadに入れました:
UIBarButtonItem *addbutton = self.navigationItem.leftBarButtonItem;
[addbutton setTarget:self];
[addbutton setAction:@selector(add)];
関数を次のように変更しました。
- (void)add {
myCustomViewController *add = [[myCustomViewController alloc] initWithNibName:@"myCustomViewController" bundle:nil];
[self presentModalViewController:add animated:YES];
[add release];
}
助けてくれてありがとう、パルト!