2
私は2つのカスタム右バーボタンアイテムを持っています。ポートレートモードでは、それらは互いにオーバーレイし、それらのうちの1つだけが表示されますが、ランドスケープモードでは両方が表示されます。アイテムは、カスタムビューで作成されます。カスタムビューは、背景イメージを持つUIButtonです。UINavigationitem custom rightBarButtonItems
optionsBUtton=[UIButton buttonWithType:UIButtonTypeCustom];
[optionsBUtton setImage:[UIImage imageNamed:@"optionsIcon.png"] forState:UIControlStateNormal];
[optionsBUtton setBackgroundImage:[UIImage imageNamed:@"optionsBtn.png"] forState:UIControlStateNormal];
[optionsBUtton sizeToFit];
UIBarButtonItem* btnOptions=[[UIBarButtonItem alloc] initWithCustomView:optionsBUtton];
searchButton=[UIButton buttonWithType:UIButtonTypeCustom];
[searchButton setImage:[UIImage imageNamed:@"searchIcon.png"] forState:UIControlStateNormal];
[searchButton setBackgroundImage:[UIImage imageNamed:@"optionsBtn.png"] forState:UIControlStateNormal];
[searchButton sizeToFit];
UIBarButtonItem* btnSearch=[[UIBarButtonItem alloc] initWithCustomView:searchButton];
rightButtonItems=[[NSArray alloc] initWithObjects:btnOptions,btnSearch, nil];
navItem.rightBarButtonItems=rightButtonItems;
なぜボタンアイテムのコレクションプロパティがある場合はツールバーを使用しますか? – taffarel
ツールバーは、ツールバーとツールバーを追加するための複数のボタン配列をサポートしています。以下のようにナビゲーション項目に追加します。 – Dinesh
Dineshに感謝しますが、項目をナビゲーション項目に直接設定する方法がある場合はツールバーを使用する理由を理解できません – taffarel