我当前正在 CurrentViewController
中执行一个方法,当我到达时,我想移动到我的 FirstViewController
(这是我想要移动到的 ViewController 的实际名称)当前正在执行的方法结束
CurrentViewController.m
-(void)methodExecutingOnCurrentViewController
{
//some code..
// what method do I call in order to load and move to my FirstViewController at this point?
// do I first initialize an instance of the ViewController I want to move to?
UIViewController *firstViewController = [[FirstViewController alloc] init];
// but now how do I actually move to this instance I've just created?
// I couldn't find the appropriate method in the class reference documentation
}
最佳答案
看看 - (void)presentModalViewController:(UIViewController *)modalViewController 动画:(BOOL)animated
Doc .
还有很多其他方法可以实现您正在寻找的目标,您使用导航 Controller 吗?然后 - (void)pushViewController:(UIViewController *)viewControllerAnimated:(BOOL)animated
就是你想要的。您还可以将该 Controller 的 View 作为 subview 添加到当前的 viewController 中。
关于objective-c - 如何以编程方式移动到另一个 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12272710/