이 코드를 사용하여 AppDelegate.h를 시작할 때 표시되는 첫 번째보기 컨트롤러가 될보기 컨트롤러를 설정할 수 있습니다. 그냥 응용 프로그램이 실행을 완료하고 초기 뷰 컨트롤러를 표시하는 것입니다대로이 기능은 즉시 호출됩니다 따라
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let storyboard = UIStoryboard(name: "MainStoryboard", bundle: NSBundle.mainBundle())
let defaults = NSUserDefaults.standardUserDefaults()
var rootViewController : UIViewController;
if (defaults.boolForKey("HasBeenLaunched")) {
// This gets executed if the app has ALREADY been launched
rootViewController = storyboard.instantiateViewControllerWithIdentifier(/*storyboard id of your login controller*/) as UIViewController
} else {
// This gets executed if the app has NEVER been launched
defaults.setBool(true, forKey: "HasBeenLaunched")
defaults.synchronize()
rootViewController = storyboard.instantiateViewControllerWithIdentifier(/*storyboard id of your configuration controller*/) as UIViewController
}
self.window?.rootViewController = rootViewController;
self.window?.makeKeyAndVisible();
return true
}
문자열을 Main.storyboard에서보기 컨트롤러의 스토리 보드 ID를 편집하고 조정하는 기억 . NSUserDefaults (실제로 유용한 클래스)에 대한 문서를 확인하고 있는지 확인하는 방법에 대해 더 잘 이해할 수 있습니다. 반환하기 전에 마지막 두 문은 기본적으로 if 내부에서 선택된보기 컨트롤러를 표시합니다.
희망이 도움이됩니다.
당신이 시도한 것의 실제 예를 게시하십시오 ... – Ajean