Ios 向UINavigationController添加多个按钮
下面的代码为导航控制器添加了一些按钮。我需要这个,这样我就可以有一个工具栏上有多个项目Ios 向UINavigationController添加多个按钮,ios,uinavigationcontroller,Ios,Uinavigationcontroller,下面的代码为导航控制器添加了一些按钮。我需要这个,这样我就可以有一个工具栏上有多个项目 CGRect frame = self.navigationController.navigationBar.frame; frame.size.height += 0.01f; UIToolbar *tb= [[UIToolbar alloc] initWithFrame:frame]; NSMutableArray *tbitems = [NSMutableArray array]; tb.autor
CGRect frame = self.navigationController.navigationBar.frame;
frame.size.height += 0.01f;
UIToolbar *tb= [[UIToolbar alloc] initWithFrame:frame];
NSMutableArray *tbitems = [NSMutableArray array];
tb.autoresizingMask= UIViewAutoresizingFlexibleWidth;
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:NULL];
bi.style = UIBarButtonItemStyleBordered;
[tbitems addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[tbitems addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];
bi.style = UIBarButtonItemStyleBordered;
[tbitems addObject:bi];
[bi release];
tb.items = tbitems;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tb];
[tb release];
这在肖像画中效果很好,但在风景画中效果不太好!最后有一个缺口,我不知道如何让它填补这个缺口
在iOS 5 SDK中,您可以将多个
uiBarButtonims
设置为右按钮或左按钮。否,这就是我上面所做的,但有一个间隙