【发布时间】:2013-10-15 03:38:32
【问题描述】:
我有这段代码用于 iPad 应用程序,它适用于 iOS 7 以下的任何 iOS
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 75, 44)];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *composeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(toggleDelete:)];
[buttons addObject:composeButton];
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedSpace.width = 5;
[buttons addObject:fixedSpace];
UIBarButtonItem* bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(touchMe:)];
[buttons addObject:bi];
[tools setItems:buttons animated:NO];
tools.barStyle = -1;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[bi release];
[fixedSpace release];
[composeButton release];
[buttons release];
[tools release];
这个pre iOS 7的结果是:
在 iOS 7 上运行相同的代码会产生以下结果:
由于某种原因,按钮在 iOS 7 中被移到了工具栏的底部。
现在,我可以使用 UIBarItem imageInset 属性重新定位它们,但这似乎有点骇人听闻,因为那时我需要检查 iOS 版本,并且只有在 iPad 运行 iOS 7+ 时才执行 imageInset。我的问题是我是否遗漏了与 UIToolbar 相关的 iOS 7 特有的任何内容?我查看了 iOS 7 UI 转换指南,但找不到任何特定于此问题的内容。
【问题讨论】:
标签: ios objective-c ipad ios7 uitoolbar