2017-04-20 4 views
0

View Controller 모달을 표시하려고합니다. 그래서 새로운 탐색 컨트롤러를 만들고 initWithRootViewController을 호출했습니다. 문제는 탐색 모음에 취소 버튼을 만들려고하지만 그냥 할 수 없다는 것입니다. 먼저 Navigation Controller가 아닌 외부에서 탐색 바에 버튼과 텍스트를 설정할 수 있습니까?iOS, Objective C NavigationController 모달 제시 및 취소 버튼 추가

새로운 맞춤 설정을 설정하면 작동하지 않을 수 있습니다. navigationItem?

+0

여기에서 직면 한 문제는 무엇입니까? – KKRocks

+0

탐색 모음의 왼쪽에 취소 텍스트를 표시 할 수 없습니다. – Secondwave

+0

취소 버튼을 추가하는 방법은 무엇입니까? – KKRocks

답변

0

혼자서 문제가 해결되었습니다. 문제는 내가 루트 컨트롤러에서 내 취소 버튼을 설정해야하고 내비게이션 컨트롤러에서는 외부에서가 아니라는 것입니다.

0

예 네비게이션 바 상단에 취소 버튼과 제목을 모두 추가 할 수 있습니다.

탐색 컨트롤러에보기 컨트롤러를 포함시키고 탐색 컨트롤러에 storyboadId를 제공하십시오. 그런 다음 버튼 액션 사용이

를이 코드

UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] 
          initWithTitle:@"Flip"            
          style:UIBarButtonItemStyleBordered 
          target:self 
          action:@selector(cancelButtonAction:)]; 
self.navigationItem.rightBarButtonItem = flipButton; 
self.navigationItem.title = @"Wishlist"; 

추가) (의 viewDidLoad에서 원하는 클래스에서 당신은 VC

UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"]; 
[self presentViewController:initialNavigationController animated:YES completion:nil]; 

원하는 선물을 취소 할에서 어떤 클래스의 코드를 추가

- (IBAction)cancelBtnAction:(id)sender 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 
관련 문제