我試圖創建一個UIBarButton,並使用代碼將它添加到工具欄中。我在運行應用程序後丟失了我的按鈕邊框。我的代碼如下所示。Objective C:在工具欄中缺少UIBarButton的邊框
//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
您是否嘗試了'UIBarButtonItemStylePlain'按鈕以外的樣式? – 2011-04-22 15:30:16
是的,謝謝!我找到了一個邊框。非常感謝 – Zhen 2011-04-22 15:33:43