无法使用故事板跳过ViewController

时间:2013-11-13 07:36:05

标签: ios iphone ios7 apple-push-notifications appdelegate

我收到通知但我的应用程序没有运行,我通过通知打开应用程序,所以我不能跳过ViewController。 那是我的代码。

AppDelegate.m

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    UIApplicationState state = [application applicationState];
    if (state == UIApplicationStateActive)
    {
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];

        if([[NSUserDefaults standardUserDefaults] valueForKey:@"username"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"password"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"companyid"])
        {
            HomeViewController  *hm= [storyBoard instantiateViewControllerWithIdentifier:@"HomeView"];
            self.window.rootViewController = hm;
        }
        else
        {
            NSLog(@"LoginView");
        }
    }
    else
    {
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];

        if([[NSUserDefaults standardUserDefaults] valueForKey:@"username"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"password"] && [[NSUserDefaults standardUserDefaults] valueForKey:@"companyid"])
        {
            HomeViewController  *hm= [storyBoard instantiateViewControllerWithIdentifier:@"HomeView"];
            self.window.rootViewController = hm;
        }
        else
        {
            NSLog(@"LoginView");
        }
    }
}

0 个答案:

没有答案
相关问题