12
我正在使用一個故事板,並且我有一個拆分視圖,其中主人是UITableViewController。就像iPad Mail應用程序一樣,我想顯示一個UIToolbar。UIToolbar不顯示UIBarButtonItem
我無法通過故事板添加工具欄,但我設法以編程方式添加它。我也可以添加一個UILabel到工具欄,但我找不到添加刷新按鈕或任何種類的UIBarButtonItem的方法。
有什麼想法?
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setToolbarHidden:NO];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50.0f, 0.0f, 80.0f, 40.0f)];
label.text = @"last updated...";
label.textAlignment = UITextAlignmentCenter;
label.font = [UIFont systemFontOfSize:13.0];
[self.navigationController.toolbar addSubview:label];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStylePlain target:self action:@selector(action:)];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"Item1" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];
NSArray *buttons = @[item1, item2, nil];
[self.navigationController.toolbar setItems:buttons animated:NO];
ü救了我的天!.... Thanksss – sheetal
媽的,謝謝!這節省了時間!謝謝! – yohannes