2016-06-01 2 views
0

와 내가 TabBar의 컨트롤러에 로그인 페이지에서 SEGUE를 만들려고하면, 내 응용 프로그램은 경고 아래에 더 이상이 번들에 NIB를로드 할 수 없습니다 : 'NSBundle를 아이폰 OS에 스위프트

입니다 실행되지 않습니다.

2016-06-01 18:15:49.255 noonting[62702:982483] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/HK/Library/Developer/CoreSimulator/Devices/F801E079-1231-47D6-B108-0644D7F82931/data/Containers/Bundle/Application/48A07480-11CA-4140-AA53-A405473635C3/noonting.app> (loaded)' with name 'Home' and directory 'Main.storyboardc'' 
*** First throw call stack: 
(
    0 CoreFoundation      0x000000010e6b4d85 __exceptionPreprocess + 165 
    1 libobjc.A.dylib      0x0000000110458deb objc_exception_throw + 48 
    2 CoreFoundation      0x000000010e6b4cbd +[NSException raise:format:] + 205 
    3 UIKit        0x000000010f2a4c89 -[UINib instantiateWithOwner:options:] + 499 
    4 UIKit        0x000000010f61f314 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181 
    5 UIKit        0x000000010f61f467 -[UIStoryboard instantiateInitialViewController] + 69 
    6 UIKit        0x000000010eedc89f -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 94 
    7 UIKit        0x000000010eedcbcf -[UIApplication _loadMainInterfaceFile] + 260 
    8 UIKit        0x000000010eedb3ef -[UIApplication _runWithMainScene:transitionContext:completion:] + 1392 
    9 UIKit        0x000000010eed8714 -[UIApplication workspaceDidEndTransaction:] + 188 
    10 FrontBoardServices     0x00000001123138c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 
    11 FrontBoardServices     0x0000000112313741 -[FBSSerialQueue _performNext] + 178 
    12 FrontBoardServices     0x0000000112313aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45 
    13 CoreFoundation      0x000000010e5da301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 
    14 CoreFoundation      0x000000010e5d022c __CFRunLoopDoSources0 + 556 
    15 CoreFoundation      0x000000010e5cf6e3 __CFRunLoopRun + 867 
    16 CoreFoundation      0x000000010e5cf0f8 CFRunLoopRunSpecific + 488 
    17 UIKit        0x000000010eed7f21 -[UIApplication _run] + 402 
    18 UIKit        0x000000010eedcf09 UIApplicationMain + 171 
    19 noonting       0x000000010e0f7be2 main + 114 
    20 libdyld.dylib      0x0000000110f2592d start + 1 
    21 ???         0x0000000000000001 0x0 + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

첫 번째 시도 코드는 다음과 같습니다. "홈"TabBar의 컨트롤러의 식별자 내 두 번째 시도 코드의

self.performSegueWithIdentifier("Home", sender: nil) 

let appDelegate = UIApplication.sharedApplication().delegate! as! AppDelegate 

let initialViewController = self.storyboard!.instantiateViewControllerWithIdentifier("Home") //as! UIViewController 
appDelegate.window?.rootViewController = initialViewController 
appDelegate.window?.makeKeyAndVisible() 

부분 다음과 같습니다 :

let storyboard: UIStoryboard = UIStoryboard(name:"Main", bundle: NSBundle.mainBundle()) 
let tabBarController: UITabBarController = storyboard.instantiateViewControllerWithIdentifier("Home") as! UITabBarController 

답변

0

당신은 페이지 사이 SEGUE 만들어나요? 섹터 identifier을 "홈"으로 설정 했습니까? 그렇다면, 단 한 줄의 코드 만 왼쪽, 당신이 당신의 TabBar의 컨트롤러 ID를 설정 않은 경우는 (당신이 스토리 보드를 사용하기 때문에,이 Storyboard ID 필드 TabBar의 컨트롤러의 신원 관리자에), 반면에

self.performSegueWithIdentifier("Home", sender: nil) 

를 작동합니다 "Home"으로 변경하려면 다음 코드를 사용하십시오.

let appDelegate = UIApplication.sharedApplication().delegate! as! AppDelegate 

let initialViewController = self.storyboard!.instantiateViewControllerWithIdentifier("Home") //as! UIViewController 
appDelegate.window?.rootViewController = initialViewController 
appDelegate.window?.makeKeyAndVisible() 

로그에이 식별자를 설정하지 않았다는 메시지가 표시됩니다. segue 식별자와 함께 사용하지 마십시오. 이것은 다른 것이므로 다른 문자열을 사용하는 것을 선호합니다.

관련 문제