1
我在我的视图控制器中的代码在视图中没有这样的负载..但UIBarButtonItem不在工具栏的右侧。它在左侧。任何帮助?如何给工具栏的标题也?UIBarbuttonItem不在工具栏的右侧?
UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlackTranslucent;
// create a bordered style button with custom title
UIBarButtonItem *playItem = [[[UIBarButtonItem alloc] initWithTitle:@"Play"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(flipToSchedules:)] autorelease];
self.navigationItem.rightBarButtonItem = playItem;
NSArray *items = [NSArray arrayWithObjects: playItem, nil];
toolbar.items = items;
// size up the toolbar and set its frame
// please not that it will work only for views without Navigation toolbars.
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGRect mainViewBounds = self.view.bounds;
[toolbar setFrame:CGRectMake(0, 20,
CGRectGetWidth(mainViewBounds), toolbarHeight)];
[self.view addSubview:toolbar];
的灵活宽度按钮项目肯定是要走的路, 这里。 – 2009-10-10 10:36:16