2011-07-18 5 views
2

UIToolBarとUIBarButtonアイテムを作成して追加すると、ツールバーとアイテムが両方の向きで正しく表示されます。あなたが画像から見ることができるようにUIToolbarリサイズすると、奇妙なUIBarButtonItemサイズがランドスケープで発生する

self.toolbar = [[[UIToolbar alloc]initWithFrame:CGRectMake(0, 372, 320, 44)]autorelease]; 
self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

self.deleteButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteButtonClicked)] autorelease]; 
self.deleteButton.style = UIBarButtonItemStylePlain; 

UIBarButtonItem *flexibleSpace = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease]; 

self.shareButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButtonClicked)] autorelease]; 
self.shareButton.style = UIBarButtonItemStylePlain; 
self.navigationItem.leftBarButtonItem = backItem; 

NSArray *toolbarItems = [NSArray arrayWithObjects:self.shareButton,flexibleSpace,self.deleteButton,nil]; 
[self.toolbar setItems:toolbarItems animated:NO]; 

は、UIBarButtonItemsは風景の中に、肖像画に正しく見えるが、不気味踏み付けと中央(特にゴミ箱のアイコン)オフ:これは私がこれまで持っているものです。私が紛失している明白な解決策がありますか、またはこの権利を得るために手動でサイズを変更する必要がありますか?

Portrait Orientation

Landscape Orientation

それは微妙な違いだが、ここではそれがどのように見えるかです:あなたはUIToolBarのために、両方のSize inspectorAutoresizingオプションを見ている What it should look like

+1

あなたは*これは*見えるべきであると思われることを示すことができますか? – jtbandes

+0

彼らは私に見えます... –

+0

jtbandes:ちょうど3番目のスクリーンショットで更新 –

答えて

0

少なくとも、iOS 5までは自分で作成するのではなく、UINavigationControllerのツールバーを使うことです。ビルトインされたツールバーは、正しく自動的にサイズ変更されます。

0

ボタン。 UIToolBarにチェックマークが設定されている場合は、ボタンに影響を与えないようにチェックを外してください(Autoresize subviews)。

関連する問題