CalendarViewController

CalendarViewController

本文介绍了在 Objective-C 中切换故事板视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在同一个故事板上切换到不同的 ViewController,如下所示:

I am trying to switch to different ViewController on same storyboard like so:

CalendarViewController *CalViewController = [[CalendarViewController alloc] init];[self presentViewController:CalViewController animation:NO completion:nil];

CalendarViewController *CalViewController = [[CalendarViewController alloc] init];[self presentViewController:CalViewController animated:NO completion:nil];

当我运行此操作时,相应的实现文件执行 NSLog 消息,但屏幕变黑且未显示任何错误.

When I run this action, corresponding implementation file executes NSLog message but screen goes black with no errors being displayed.

我该如何解决这个问题?

How do I fix this?

推荐答案

假设您在故事板中创建了 CalendarViewController 界面,并为其分配了标识符ControllerIdentifier".

Let's suppose you created your CalendarViewController interface in a storyboard, and you assigned it the identifier "ControllerIdentifier".

如果你想从另一个视图控制器内部加载它,你可以实例化你的 CalendarViewController 并像这样呈现它:

If you want to load it from inside another View Controller, you can instantiate your CalendarViewController and present it like this:

CalendarViewController *calViewController = (CalendarViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"ControllerIdentifier"]
[self presentViewController:calViewController animated:NO completion:nil];

这篇关于在 Objective-C 中切换故事板视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 09:46