【发布时间】:2012-10-10 03:53:22
【问题描述】:
有一个当前视图为UIViewController,它调用“LoginView”但我不在,我在一个NSObject 类中,我想调用,显示另一个UIViewController,它调用“MapView” ”。我该怎么做?
问题如上图所示。
【问题讨论】:
-
两件事:你为什么要在模型中实例化和显示视图控制器,以及what have you tried?
-
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [[appDelegate loginViewController] presentViewController:mapViewController animated:YES completion:nil];我试过那个代码但没有用.. -
您的 AppDelegate 类的名称真的是“AppDelegate”吗?此外,应该不需要从 NSObject 呈现 viewController !
-
确定是“AppDelegate”。
-
我找到了真正的代码片段。可能有人有同样的问题,所以我给他们。
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [[appDelegate window] addSubview:mapViewController.view]; [[appDelegate window] bringSubviewToFront:mapViewController.view];
标签: ios xcode4 uiviewcontroller storyboard nsobject