简体   繁体   中英

How to switch view from appdelegate?

This code from my AppDelegate from my app, which not use storyBoard, and this code switch view normaly -

-(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];
    }
}

Now, i rewrite my App with using StoryBoard..... and this code is not working...i get black window

How i can switch view from AppDelegate???

This is answer)) I Get it) =)

-(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];
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM