Objective c SetRightBarButtonims:ios4中不支持动画

Objective c SetRightBarButtonims:ios4中不支持动画,objective-c,ios,ios5,ios4,Objective C,Ios,Ios5,Ios4,iOS4不支持用于UINavigationItem的方法setRightBarButtonims:animated: 我如何重写这段代码,在工具栏右侧添加两个按钮 [viewController.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:helpButton, settingsButton, nil] animated:YES]; 谢谢,您可以在将按钮添加到视图之前将其alpha设置为0,然后将其值设置为1.

iOS4不支持用于
UINavigationItem
的方法
setRightBarButtonims:animated:

我如何重写这段代码,在工具栏右侧添加两个按钮

[viewController.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:helpButton, settingsButton, nil] animated:YES];

谢谢,您可以在将按钮添加到视图之前将其alpha设置为0,然后将其值设置为1.0

//..Create the buttons
//Make it invisible
helpButton.alpha = 0.0;
settingsButton.alpha = 0.0

//Add them to the navBar
[self.navigationController.navigationBar addSubview:helpButton];
[self.navigationController.navigationBar addSubview:settingsButton];

//Animate it to 1.0
[UIView animateWithDuration:0.3 animations:^(void) {
      helpButton.alpha = 1.0;
      settingsButton.alpha = 1.0
    }];

如果要在iOS4中显示多个按钮,必须手动创建它们

例如,您可以将标题视图设置为自定义视图,并通过覆盖ViewController的setTitle在其中执行任何操作:

- (void)setTitle:(NSString *)title
{
        UIView *titleView = (UIView *)self.navigationItem.titleView;
        if(!titleView)
        {
            titleView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 40.0)];
            titleView.backgroundColor = [UIColor greenColor];
            self.navigationItem.titleView = titleView;
        }
}

你需要使用
UIButton
而不是
UIBarButtonItem

那么,我应该使用addSubview吗?在右边显示它们的最佳方式是什么?只需设置适当的框架就可以了。这是关于(280,5)的东西-中心,我的意思是实际上它不起作用。我得到一个不兼容的指针类型,它将“uiBarButtonim*”发送到“UIView*”类型的参数。我应该使用UIView来查看普通的UIBUtton而不是UIBarButtonim吗?我就是这样做的,只是自定义UIBUtton。难道不应该有一个[标题视图发布];self.navigationItem.titleView后的行=titleView;自从你在前面分配并初始化了标题查看了3行之后,我已经习惯了ARC,以至于我几乎忘记了保留/释放的存在:)如果你不使用ARC,你当然必须插入一个释放。你没有提到按钮。你说的是头衔