右のバーボタンアイテムとしてカスタムビューのナビゲーションバーがあります。カスタムビューには2つのボタンがあります。しかし、右側のナビゲーションバーの下の領域に触れると、ボタンタッチイベントが発生します。ボタンのフレームを確認し、背景色を変更して表示しましたが、すべて完璧に設定されています。時計、カレンダー、設定、メモなどのデフォルトのiOSアプリをチェックしましたが、それらはすべて同じ動作をします。(デフォルトのiOSカレンダーアプリの)スクリーンショットの赤い長方形をタッチすると、ボタンのタッチイベントが発生します。これは私のアプリでも発生しています。
これがコードです。
UIView* navigationButtonsView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 44.0f)];
UIButton *p = [UIButton buttonWithType:UIButtonTypeCustom];
[p setImage:[UIImage imageNamed:@"PBtn.png"] forState:UIControlStateNormal];
[p addTarget:self action:@selector(PButtonPushed:) forControlEvents:UIControlEventTouchUpInside];
[p setFrame:CGRectMake(43, 0, 57, 44)];
[navigationButtonsView addSubview:p];
UIButton *o = [UIButton buttonWithType:UIButtonTypeCustom];
[o addTarget:self action:@selector(oButtonPushed:) forControlEvents:UIControlEventTouchUpInside];
[o setFrame:CGRectMake(0, 0, 38, 44)];
[o setImage:[UIImage imageNamed:@"O.png"] forState:UIControlStateNormal];
[navigationButtonsView addSubview:o];
UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:navigationButtonsView];
[musicVC.navigationItem setRightBarButtonItem: barItem animated:NO];
ナビゲーションバーボタンのこのデフォルトのiOSの動作を変更するにはどうすればよいですか?これらのボタンのすぐ下にいくつかのUIがあり、その上部領域がこのために応答しないためです。前もって感謝します..