ナビゲーションバー(ナビゲーション付き)があり、ナビゲーションバーに2つのボタンが含まれていますが、ボタンの1つを左に割り当てると、ナビゲーションボタンが消えます(doughh)。さらに2つのボタン?ここで私が使用するコード:
viewDidLoadから
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
infoButton.frame = CGRectMake(0, 10, 40, 30);
UIImage *img = [UIImage imageNamed:@"eye.png"];
[infoButton setImage:img forState:UIControlStateNormal]; [img release];
//[infoButton setTitle:@"xuxu"forState:UIControlStateNormal];
[infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[self.navigationItem setRightBarButtonItem:modalButton animated:YES];
[modalButton release];
UIButton* iButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
iButton.frame = CGRectMake(0, 10, 40, 30);
UIImage *imag = [UIImage imageNamed:@"eye.png"];
[iButton setImage:imag forState:UIControlStateNormal]; [imag release];
//[infoButton setTitle:@"xuxu"forState:UIControlStateNormal];
[infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton2 = [[UIBarButtonItem alloc] initWithCustomView:iButton];
[self.navigationItem setLeftBarButtonItem:modalButton2 animated:YES];
[modalButton2 release];
だから私の2番目のボタンはに設定されています
setLeftBarButtonItem
setCenterのようなものはありますか?またはx、yで位置を設定する方法?? ナビゲーションのためにボタンを左側に保持する2つのボタンが必要です(3つのボタン)
ありがとう!