您需要使用。 AppDelegate的
目标C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"LoginStatus"]) {
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginController"];
}else{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"RootView"];
}
}
SWIFT - 我希望它的正确
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
//Using UserDefaults check already loggedin user or not
if (!someStatus) {
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
}else{
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("loginViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
}
}
请问您可以显示注销码吗? –
注销我只是使用self.navigationController?popViewControllerAnimated(true) – Gamerlegend
来弹出currentviewcontroller你应该写let storyboard = UIStoryboard(name:“MyStoryboardName”,bundle:nil) let vc = storyboard.instantiateViewControllerWithIdentifier(“loginViewController” )as! UIViewController self.presentViewController(vc,animated:true,completion:nil)在注销 –