Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 向UINavigationController添加多个按钮_Ios_Uinavigationcontroller - Fatal编程技术网

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
设置为右按钮或左按钮。否,这就是我上面所做的,但有一个间隙