我在下面有这段代码,它基本上打开了最后保存的类。在我的实例中,这个类在故事板中,当我告诉它回忆它的类时,它正在转换为黑色。我想知道的是如何检测故事板的ID,保存它,然后从一个故事板文档中的任何故事板中的IBAction打开它。谢谢:))
保存代码:
[[NSUserDefaults standardUserDefaults] setObject:NSStringFromClass([self class]) forKey:@"currentViewController"];
[[NSUserDefaults standardUserDefaults] synchronize];
退货代码:
NSString *savedClassName = [[NSUserDefaults standardUserDefaults] objectForKey:@"currentViewController"];
Class cls = NSClassFromString(savedClassName);
UIViewController *screen = (UIViewController *)[cls new];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:screen animated:YES completion:nil];
答案 0 :(得分:1)
这里可能有2个问题。
确认两点都完成后,你可以这样做:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"UIViewController"];
[self presentViewController:vc animated:YES completion:nil];
答案 1 :(得分:0)
我最后把它放入我的返回IBAction中,很简单!!
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];