0
私はカスタムビューを持ち、UIButtonを持っています。このビューをnavigationItemのrightbarButtonItemに追加します。これは問題ありませんが、このボタンにアクションを追加する必要があります。カスタムビューでUIButtonにアクションを追加します。
ここは私のコードです。
-(void)showMessage:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"next" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
[alert show];
}
- (void)viewDidLoad {
UpDownButtonView *buttonView = [[UpDownButtonView alloc] initWithNibName:@"UpDownButtonView" bundle:nil];
[buttonView.upButton addTarget:self action:@selector(next:) forControlEvents:UIControlEventTouchUpInside];
[buttonView.downButton addTarget:self action:@selector(prev:) forControlEvents:UIControlEventTouchUpInside];
buttonView.view.frame = CGRectMake(0,0,95,34);
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:buttonView.view];
self.navigationItem.rightBarButtonItem = item;
[self setTitle:@"Details"];
[super viewDidLoad];
}
ありがとうございます。
が、ボタンや何かを追加してカスタムビューで行う必要があります。何かご意見は? – Can