2016-07-12 2 views
0

나는 내 iOS 앱에 탭 컨트롤러가 내가 먼저 일부 조건을 확인하고 다음과 같이 수행 할 :프로그램 설정 초기 뷰 컨트롤러는 2

self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
if condition { 
     globalClass.token = u 
     let mvc: MainViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("mainView") as! MainViewController 
     self.window?.rootViewController = mvc 

    } else { 
     globalClass.token = "" 
     let mvc: LoginViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("loginView") as! LoginViewController 
     self.window?.rootViewController = mvc 
    } 
    self.window?.makeKeyAndVisible() 

내 문제는 내가 프로그래밍 방식으로 설정할 때 초기에 view controller이로드되면 탭 컨트롤러의 첫 번째 탭에로드됩니다. 맨 아래의 탭 메뉴는로드되지 않습니다. 탭 메뉴가 아닌 view controller을로드하기 만하면됩니다.

MainViewController은 탭보기 컨트롤러의 첫 번째 탭

감사합니다,

아프신

+1

당신이 "초기 뷰 컨트롤러를 설정"하는 데 사용하는 코드를 게시 할 수 있습니까? 또한 프로젝트에서이 논리는 어디에 있습니까? AppDelegate? – rigdonmr

+1

그리고 작동하지 않는 "else"문에 코드를 게시 하시겠습니까? 이번에는 질문을 편집하여 주석이 아닌 게시하십시오. – rigdonmr

답변

1

이 코드를 시도입니다.

let tbc = mainStoryBoard.instantiateViewControllerWithIdentifier("tabbarStoryboardId") as! UItabBarController self.window?.rootViewController = tbc

감사

+0

고맙습니다. 프로그램을 변경 한 후 "tabbarStoryboardId"를 변경하는 것을 잊어 버렸습니다. 그것은 바보 같은 질문이었다 : | –