1

setRightBarButtonItems:animated:aのメソッドはUINavigationItem、iOS4 ではサポートされていません。

このコードを書き直して、バーの右側に 2 つのボタンを追加するにはどうすればよいですか?

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

ありがとう

4

2 に答える 2

0

ビューに追加する前にボタンのアルファを 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
    }];
于 2012-08-22T09:03:13.737 に答える
0

iOS4 で複数のボタンを表示する場合は、手動で作成する必要があります。

たとえば、titleView をカスタム ビューに設定し、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

于 2012-08-22T09:13:24.117 に答える