1

내 MainWindow.xib 내에 아래에있는 설정이 있습니다. Tab Bar Controller 내에 Navigation Controller가있는 Tab Bar Controller가 있습니다. 서로 다른 네비게이션 컨트롤러를 전환 할 수 있으며이 모든 기능이 작동합니다.탭 바 컨트롤러 + 탐색 컨트롤러 + 바 버튼 항목

내가 지금하려는 것은 네비게이션 컨트롤러에 오른쪽 바 버튼 항목을 추가하는 것입니다. Interface Builder를 사용하여 Navigation Controller로 드래그 앤 드롭 할 수 없습니다. 내비게이션 컨트롤러에 버튼을 추가하는 방법이 있나요? 특정보기에 대해 단추를 추가하거나 더 바람직하게는 모든보기에 걸쳐 단추를 추가하는 것이 좋습니다.

Tab Bar Controller 
    Tab Bar 
    Navigation Controller 
     Navigation Bar 
     XXXXViewController 
     Tab Bar Item 

답변

4

당신은 당신이 바로 바 버튼을 원하고 당신이 버튼을 할 것을하려는 작업에 따라 그 선택에 메소드를 호출 컨트롤러의 프로그래밍의 viewDidLoad에서 그것을 할 수 있습니다.

UIBarButtonItem *comment = [[UIBarButtonItem alloc] 
          initWithBarButtonSystemItem:UIBarButtonSystemItemCompose 
          target:self 
          action:@selector(displayViewForPosts)]; 

self.navigationItem.rightBarButtonItem = comment; 
[comment release];