我只想显示一个“CreditsView”。因此,如果我按下按钮显示积分 View ,按确定 View 将消失。

我有我的基本 Controller 和我的积分 View Controller ,现在我尝试类似的东西:

- (IBAction)switchToCreditsView:(id)sender {
creditsViewController = [[CreditsViewController alloc] initWithNibName:@"CreditsViewController"];
[self.view addSubview:creditsViewController.view];
//[self presentModalViewController:creditsViewController animated:YES];

}

但是如果我按下按钮,我的应用程序就会崩溃。

最佳答案

要返回,您只需调用:

- (IBAction)switchToBaseView:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

关于iphone - 如何从 Controller 显示和关闭 View ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1420357/

10-12 21:29