2011-04-22 46 views
1

我試圖創建一個UIBarButton,並使用代碼將它添加到工具欄中。我在運行應用程序後丟失了我的按鈕邊框。我的代碼如下所示。Objective C:在工具欄中缺少UIBarButton的邊框

UIBarButton without border

//Add toolbar to the UITable View 
toolbar = [[UIToolbar alloc] init]; 
toolbar.barStyle = UIBarStyleDefault; 
toolbar.frame = CGRectMake(0, 436, 320, 50); 

//Set the toolbar to fit the width of the app. 
[toolbar sizeToFit]; 

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

UIBarButtonItem *nextButton = [[UIBarButtonItem alloc]initWithTitle:@"Who Paid?" 
                   style:UIBarButtonItemStylePlain 
                  target:self 
                  action:nil]; 

NSArray *buttonItems = [[NSArray alloc]initWithObjects:flexButton, nextButton, nil]; 

[self.toolbar setItems:buttonItems]; 

[self.navigationController.view addSubview:toolbar]; 


[buttonItems release]; 
[flexButton release]; 
[nextButton release]; 
[toolbar release]; 

難道我錯過了任何一個步驟或者是有這是犯了一個錯誤?任何幫助,這是非常感謝。

謝謝!

Zhen

+0

您是否嘗試了'UIBarButtonItemStylePlain'按鈕以外的樣式? – 2011-04-22 15:30:16

+0

是的,謝謝!我找到了一個邊框。非常感謝 – Zhen 2011-04-22 15:33:43

回答

3

UIBarButtonItemStylePlain是罪魁禍首。

據,UIBarButtonItemStyleBordered是你所需要的:

UIBarButtonItemStylePlain:當竊聽 發光。默認的項目樣式。

UIBarButtonItemStyleBordered:簡單的 帶邊框的按鈕樣式。

UIBarButtonItemStyleDone:該風格 一個完成按鈕,例如,完成一些任務並返回 上一個視圖按鈕 。

+0

非常感謝!我發現另一個說接壤的。傻我。 – Zhen 2011-04-22 15:34:14

+0

啊我的不好,抱歉,謝謝:) – 2011-04-22 17:45:08