我有一個導航欄(導航),我已經包括2個按鈕導航欄,但如果我分配一個按鈕左,我的導航按鈕消失(doughh), 所以我怎麼能,我的導航按鈕,還有2個按鈕? 這裏的代碼我使用:iphone 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];
所以我的第二個按鈕被設置爲
setLeftBarButtonItem
有像setCenter什麼?或者用x,y設置位置的方法? 我需要2個按鈕保留我的按鈕左側用於導航目的(3個按鈕)
謝謝!
上添加兩個或更多的按鈕,你需要三個按鈕2左1右。 – Ishu 2011-02-25 04:15:57