2012-01-16 13 views

答えて

0

左側の最後のアイテムと右側のアイテムの間に柔軟なスペースを追加できます。

NSMutableArray *itemArray [[NSMutableArray alloc] init]; 

// Add items to the left 
... 

// Add flexible item to push everything else to the right 
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] inithWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
     target:nil 
     action:nil]; 
[itemArray addObject:flexItem]; 
[flexItem release]; 

// Add items to the right 
... 

self.toolbarItems = itemArray; 
[itemArray release]; 
+0

UITabBarControllerのUITabBarを編集することは不可能です。プロパティはreadonly – gsempe

+1

ああ申し訳ありません。私はツールバーがタブバーではないと思っていました。私はあなたがタブバーに空のタブを追加することによって話していることを行っています。 UITabbarContollerDelegateメソッドtabBarController:shouldSelectViewController:を使用して、空のタブに対してNOを返します。 – jimmyg

+0

UIViewContainers時代以前は唯一可能な解決策のようです – gsempe

1

Iはタイトルと画像と範囲外の値を持つタグのゼロとUITabBarItemをインスタンス化するであろう。

UITabBarItem *flexItem = [[UITabBarItem alloc] initWithTitle:nil image:nil tag:999]; 

これらをアイテム配列に追加して、希望するエフェクトを作成します。タブバーで

aTabBar.items = @[item1, item2, flexItem, flexItem, item3]; 

:didSelectItem:コールバックは、あなたのアイテムを処理するためのスイッチケースを追加し、デフォルトのケースを通じてflexItemの秋を聞かせて。

関連する問題