【发布时间】:2011-05-18 12:12:40
【问题描述】:
在 iPhone 和 iPad 上,我都需要在导航栏的右侧显示两个按钮。我正在使用以下 sn-p 代码执行此操作:
UIToolbar *rightBarButtons = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 92, 44.01)];
UIBarButtonItem *send = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(send)];
[send setStyle:UIBarButtonItemStyleBordered];
UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(addRecipe:)];
[add setStyle:UIBarButtonItemStyleBordered];
NSArray *buttons = [[NSArray alloc] initWithObjects:send,add,nil];
[send release];
[add release];
[rightBarButtons setItems:buttons];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBarButtons];
[buttons release];
[rightBarButtons release];
在 iPhone 上颜色很好,在 iPad 上的横向模式下很好,因为它们是灰色的。然而,在纵向模式下,视图出现在具有深黑色/蓝色的弹出框控制器内。我的按钮和工具栏显示为默认灰色。
如何使工具栏按钮匹配?如果你不使用上面的技巧,只是像平常一样显示一个按钮,颜色变化就会被处理,我想我只需要手动实现颜色变化,问题是,我似乎根本无法改变颜色。
【问题讨论】:
标签: iphone ipad uinavigationcontroller uisplitviewcontroller uipopovercontroller