任何人都可以幫助我如何使用標題視圖屬性將兩個按鈕添加到導航標題視圖。我試過,但能夠使用下面的代碼只能添加一個按鈕。如何將兩個按鈕添加到UINavigation欄標題視圖
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
customView.backgroundColor = [UIColor redColor];
UIButton *b1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
UIButton *b2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
[b1 setTitle:@"Hai" forState:UIControlStateNormal];
[b2 setTitle:@"Hello" forState:UIControlStateNormal];
[customView insertSubview:b1 atIndex:0];
[customView insertSubview:b2 atIndex:1];
self.navigationItem.titleView = customView;
什麼關於我的這個答案嘗試這個,你做了一些MINORE錯誤看看這個http://stackoverflow.com/問題/ 16958913 /如何添加項目在uinavigationbar特定位置/ 16959449#16959449 –