我在我的TabBarView中有一個導航欄。我想要一個rightBarButtonItem和我的導航欄上的標題。這是爲什麼發生?我的代碼在viewDidLoad方法中。爲什麼我的標題顯示爲左鍵項目?然後當我點擊它時,它就像移動了一個視圖,然後我的右欄按鈕項消失了,標題正確。爲什麼我的標題顯示爲左鍵?
UINavigationBar *myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320,40)];
myNavBar.barStyle = UIBarStyleBlackOpaque;
[self.view addSubview:myNavBar];
//Creates the title.
UINavigationItem *title = [[UINavigationItem alloc] initWithTitle:@"My Title"];
[myNavBar pushNavigationItem:title animated:NO];
//Creates the button.
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self
action:@selector(showMail:)];
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:nil];
navItem.rightBarButtonItem = button;
// add the UINavigationItem to the navigation bar
[myNavBar pushNavigationItem:navItem animated:NO];
爲什麼會發生什麼? – 2013-05-06 20:31:52
問題的標題說最新發生的笑。也許我應該在那裏包含它。爲什麼我的標題顯示爲左鍵項目?然後當我點擊它時,它會動作,它正在移動一個視圖,然後我的右側欄按鈕項目消失,標題正確。 – Jason 2013-05-06 20:34:59