-3

私のアプリケーションでは、ナビゲーションバーの右バーボタンの代わりに2つのボタン(それぞれ異なるアクションを持つ)を表示したいと思います。どうすればいいですか?

4

2 に答える 2

5

これがあなたがその働きを望みそして助けるコードです

以下のコードを入れてください

 -(void)viewWillAppear:(BOOL)animated 
  {
     UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 103.0f, 44.01f)];
     tools.tintColor = [UIColor clearColor];

     [tools setBarStyle:UIBarStyleBlackTranslucent];
     tools.barStyle = -1; // clear background
     NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:3];

    // Create a standard refresh button.

     UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
     [button setImage:[UIImage imageNamed:@"Settings.png"] forState:UIControlStateNormal];
     [button addTarget:self action:@selector(resetpass) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 30,30 )];
bi = [[UIBarButtonItem alloc] initWithCustomView:button];

[buttons addObject:bi];
[bi release];

bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
bi.width = 2.0f;
[buttons addObject:bi];
[bi release];

// Add profile button.
bi = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(createnewFolders)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];

// Add buttons to toolbar and toolbar to nav bar.
[tools setItems:buttons animated:NO];
[buttons release];
twoButtons = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];

self.navigationItem.leftBarButtonItem = twoButtons;

[twoButtons release];
 }

ありがとうございました

于 2012-09-25T09:09:41.847 に答える
1

この投稿があなたの質問に答えると思います。

ただし、質問に正しく答えるには、より多くの情報が必要です。iOS版など。その答えはあなたが要求しているものを持っているようです。

于 2012-09-24T23:38:52.410 に答える