如何从appdelegate切换视图?

时间:2013-04-21 18:55:59

标签: iphone ios objective-c storyboard

这个代码来自我的AppDelegate,来自我的应用程序,它不使用storyBoard,而且这个代码切换视图正常 -

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        LN_ShowNoteVC *showVC = [[LN_ShowNoteVC alloc] init];
        _iconBage = _iconBage - 1;
        showVC.number = _showP;
        NSLog(@"showVC.number = %i", _showP);
        _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        _window.rootViewController = showVC;
        [_window makeKeyAndVisible];
    }
}

现在,我使用StoryBoard重写了我的应用程序.....这段代码无效......我得到了黑色的窗口

如何从AppDelegate切换视图???

1 个答案:

答案 0 :(得分:0)

这是答案))我明白了)=)

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        LN_ShowNoteVC *showVC = [[LN_ShowNoteVC alloc] init];
        _iconBage = _iconBage - 1;
        showVC.numberPhoto = _showP;
        NSLog(@"showVC.numberPh = %i", _showP);            
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"ShowN"];
        vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        _window.rootViewController = vc;
        [_window makeKeyAndVisible];
    }
}