UIBarButtonItem不会在iOS 7中的UIToolbar上显示

时间:2013-11-13 19:16:53

标签: ios uibarbuttonitem uitoolbar

在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];
}

这在以前的版本中运行良好,我现在可能会遇到什么问题。

1 个答案:

答案 0 :(得分:2)

设置色调颜色。在我的情况下工具栏是黑色的。所以我将色调设置为白色并且有效。