lundi 26 janvier 2015

How To Make Third View Controller The Root ViewController

I really need help in this situation in code I've been stuck on for 3 hours. So basically here's my code:



UIViewController* vc = (UIViewController*)[[UIStoryboard storyboardWithName:@"iPhone4" bundle:nil] instantiateViewControllerWithIdentifier:@"MyViewCo ntrollerIdentifier"];
UIViewController* vc2 = (UIViewController*)[[UIStoryboard storyboardWithName:@"iPhone4" bundle:nil] instantiateViewControllerWithIdentifier:@"MyViewCo ntrollerIdentifier22"];


Class c = NSClassFromString(@"iPhone4Level1");
Class c2 = NSClassFromString(@"iPhone4Level3");


if ([vc class] == c) {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"currentViewController"] isEqualToString:@"iPhone4Level1"])
{
[self.window setRootViewController: vc];
}
}

if ([vc2 class] == c2) {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"currentViewController3"] isEqualToString:@"iPhone4Level3"])
{
[self.window setRootViewController: vc2];
}
}


This code is a code I made in App delegate for an app I'm working on. So far if the user opens the app to the second viewcontroller which in the code is called vc they will stay on that view controller even if they kill the app because in the code it becomes the root. Now how do I accomplish the same thing with the third viewcontoller? In the code vc2 is the third viewcontroller and what I'm trying to do is make the third viewcontroller the root viewcontroller when the user gets on it. Well the problem is that in order for this to happen I have to make [self.window setrootviewcontroller = vc] = FALSE. So how would I be able to do this?


Aucun commentaire:

Enregistrer un commentaire