1

S.O에서 검색 한 적이 있지만 비슷한 기사를 찾았지만 해결책이 없습니다. 다음은 내 뷰 계층 구조의 스크린 샷은 다음과 같이 내가 시도 코드의 많은 조각의 enter image description here탭 표시 줄 컨트롤러 -> 탐색 컨트롤러 ->보기 계층 구조 - iOS Swift가 포함 된 응용 프로그램 대리인의 현재보기

하나입니다 :

  var storyBoard = UIStoryboard() 
      if UIDevice.current.userInterfaceIdiom == .pad { 
       storyBoard = UIStoryboard(name: "iPad", bundle: nil) 
      } else { 
       storyBoard = UIStoryboard(name: "Main", bundle: nil) 
      } 


      let tabVc = self.window?.rootViewController as! UITabBarController 


      let mynVC = storyBoard.instantiateViewController(withIdentifier: "nav") as! UINavigationController 


      let calcVc = storyBoard.instantiateViewController(withIdentifier: "destVc") 


      tabVc.present(mynVC, animated: true, completion: {() -> Void in 
       // Segue , do stuff 

      }) 

위의 코드는 탐색 모음에 올바른 탭을 제시하지만이 금기가 없다.

내비게이션 막대와 탭바가있는 탭을 제공하는 강제 터치 버튼을 갖고 싶습니다. 누구나 그 방법을 알고 있습니까?

+0

이유를 보여주기 위해) 아래 가지고, 당신은 또한 window.setKeyAndVisible을 (문의해야 다른 내용에 따라 내비게이션 컨트롤러를 표시하는 탭 막대보기 컨트롤러입니까? 탭 막대보기 컨트롤러에서 탐색 컨트롤러를 현재 컨트롤러로 설정해야합니다. 이 탐색 컨트롤러가 배열의 항목 중 하나 인 탭 막대보기 컨트롤러에보기 컨트롤러 배열을 설정해야 할 수도 있습니다. –

답변

3

현재이 기능을 완전히 테스트 할 수는 없지만 탭 막대에서보기 컨트롤러를 제공하지 않는다고 생각합니다. 뷰 컨트롤러 항목과 selectedViewController 속성을 설정합니다.

이 작동해야 내가 곧 그것을 업데이트를 테스트 할 수 있습니다,

var storyBoard = UIStoryboard() 
     if UIDevice.current.userInterfaceIdiom == .pad { 
      storyBoard = UIStoryboard(name: "iPad", bundle: nil) 
     } else { 
      storyBoard = UIStoryboard(name: "Main", bundle: nil) 
     } 


     let tabVc = self.window?.rootViewController as! UITabBarController 

     let mynVC = storyBoard.instantiateViewController(withIdentifier: "nav") as! UINavigationController 

     let calcVc = storyBoard.instantiateViewController(withIdentifier: "destVc") 

     tabVc.viewControllers = [mynVC] 
     tabVc.selectedViewController = mynVC 

실제로

+0

완벽하게 작업 했으므로 실제 프로젝트의 다른 탭을 추가하기 위해 tabVc.viewController = [mynVC]를 편집했습니다. 이것은 제가 찾고 있던 정확한 결과를 만들어내는 것 같습니다. 고맙습니다, 시험에 나서 승인 된 대답으로 표시하십시오. – Jerland2

+0

위대한, 도와 줘서 기뻐 :) 프로젝트와 함께 행운을 빌어 요 – Scriptable

+0

빠른 컨트롤러, 그리고 내가보기 컨트롤러를 보여주고 싶다면이 구현으로 다른 하나에 segue. 나는 "calcVc.performsegue (withIdentifier :"testSegue ", sender : self)"라고 부를 것인가? – Jerland2