アプリのメインビューで、UIBarButtonItem
カスタム画像(を使用して作成[UIImage imageNamed:]
)を使用して3つ(実際のボタン2つと柔軟なスペーサー1つ)をインスタンス化し、それらをのアイテムとして設定しますUIToolBar
。コードは次のとおりです。
-(void)viewDidLoad{
[super viewDidLoad];
UIToolbar *menuBar = [UIToolbar new];
menuBar.barStyle = UIBarStyleDefault;
CGRect viewBounds = [UIScreen mainScreen].bounds;
//menuBar is rotated to be viewed vertically along the right side of the device in portrait orientation, the app does not support device rotation
menuBar.transform = CGAffineTransformRotate(menuBar.transform, M_PI * 0.5f);
[menuBar setFrame:CGRectMake(viewBounds.size.width - menuBarHeight, 5, menuBarHeight, viewBounds.size.height)];
[self.view addSubview:menuBar];
[menuBar release];
UIBarButtonItem
*peekButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"peekIcon.png"]
style:UIBarButtonItemStyleDone
target:self
action:@selector(peek:)],
*pauseButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"pauseIcon.png"]
style:UIBarButtonItemStyleDone
target:self
action:@selector(pauseGame:)],
*flexSpace = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
menuBar.items = @[flexSpace, pauseButton, peekButton];
[flexSpace release];
[pauseButton release];
[peekButton release];
}
iOS5.1を実行しているiPodtouchで実行すると、ツールバーとボタンは次のように期待どおりに表示されます。
ただし、iPad(iOS 4.3)で実行すると、テクスチャは次のようになります。
原因を特定できないようですが、下にあるオブジェクトのデータを完全に無視してUI要素が描画されるという同様にあいまいなグラフィックの問題が発生し続けるため、OSまたはデバイス固有のバグである可能性があります。残念ながら、この問題に光を当てる関連ドキュメント(Appleまたはその他の賢明なもの)を見つけることができません。
どんな入力でも大歓迎です、ありがとう。