Iphone 如何从appdelegate切换视图?
来自我的应用程序的此代码来自我的应用程序(不使用情节提要),此代码正常切换视图-Iphone 如何从appdelegate切换视图?,iphone,ios,objective-c,storyboard,Iphone,Ios,Objective C,Storyboard,来自我的应用程序的此代码来自我的应用程序(不使用情节提要),此代码正常切换视图- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { LN_ShowNoteVC *showVC = [[LN_ShowNoteVC alloc] init]; _iconBage = _iconBa
-(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];
}
}
现在,我用故事板重写我的应用。。。。。而这个代码不起作用…我得到了黑色的窗口
如何从AppDelegate切换视图??(这是答案)我明白了)
为什么要创建另一个UIWindow实例?为什么不使用应用程序委托中已有的窗口对象?
-(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];
}
}