[英]UIBarButtonItem does not show on UIToolbar in iOS 7
在iOS 7中,UIBarButtonItem不显示在我在桌面视图底部弹出的UIToolbar上。
UIToolbar *actionToolbar;
UIBarButtonItem *actionButton;
我这样添加它:
actionToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 524, 320, 44)];
actionButton =
[[[UIBarButtonItem alloc]
initWithTitle:@"Delete"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(noAction:)]
autorelease];
[actionToolbar setItems:[NSArray arrayWithObject:actionButton]];
以下是显示UIToolbar的代码:
- (void)showActionToolbar:(BOOL)show
{
CGRect toolbarFrame = actionToolbar.frame;
CGRect tableViewFrame = self.tableView.frame;
if (show)
{
TOOLBAR_DISPLAYED = TRUE;
toolbarFrame.origin.y = actionToolbar.superview.frame.size.height - toolbarFrame.size.height;
tableViewFrame.size.height -= toolbarFrame.size.height;
}
else
{
TOOLBAR_DISPLAYED = FALSE;
toolbarFrame.origin.y = actionToolbar.superview.frame.size.height;
tableViewFrame.size.height += toolbarFrame.size.height;
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
actionToolbar.frame = toolbarFrame;
self.tableView.frame = tableViewFrame;
//I use this now in iOS7 to show the toolbar as purple otherwise it shows white
actionToolbar.superview.backgroundColor = [UIColor colorWithRed:0.10 green:0.10 blue:0.43 alpha:0.5];
[UIView commitAnimations];
}
这在以前的版本上工作正常,我现在可能会遇到什么问题。
设置色调颜色。 在我的情况下工具栏是黑色的。 所以我将色调设置为白色并且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.