我使用以下代码从主视图 ( ViewController.h
) 切换到另一个视图 ( TouchViewController
),然后类似地从该视图切换到下一个视图 ( QuestionsViewController
)。
如何从这里返回主视图?即 for 的价值是initWithNibName
什么MainStoryboard.storyboard
?
- (IBAction)startGame:(UIButton *)sender {
TouchViewController *second = [[TouchViewController alloc] initWithNibName:@"TouchViewController" bundle:nil];
[self presentViewController:second animated:YES completion:nil];
}
和
- (IBAction)selectTopic:(UIButton *)sender {
NSString *category = [[sender titleLabel] text];
[[NSUserDefaults standardUserDefaults] setObject:category forKey:@"MyKey"];
QuestionsViewController *second = [[QuestionsViewController alloc] initWithNibName:@"QuestionsViewController" bundle:nil];
[self presentViewController:second animated:YES completion:nil];
}
现在回到主视图我有一个问题,即
- (IBAction)backtoMainMenu:(id)sender {
ViewController *second = [[ViewController alloc]initWithNibName:@"MainStoryboard.storyboard" bundle:nil];
[self presentViewController:second animated:YES completion:nil];
}
此时应用程序崩溃了!我想这是因为initWithNibName:@"MainStoryboard.storyboard"
无法使用但ViewController
没有任何其他xib
文件 - 那我该怎么办?