objective-c - 如何以编程方式移动到另一个 UIViewController?

标签 objective-c ios uiviewcontroller

我当前正在 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/

相关文章:

Swift:rootViewController 永远不会调用其 view[Will/Did]Disappear 方法

objective-c - 对四边形的坐标进行排序

ios - 如何停止覆盖数据

ios - 从 key 字符串生成 64 字节长的 NSData

ios - UITabBarController + UINavigationController 和更多选项卡黑屏问题

ios - 如何通过按下单独 View 中的按钮来增加标签?

ios - 将数据从第一个 VC 传递到第三个 (Swift)

ios - 如何去除UIPageViewController的底部空隙

ios - 通过 PHFetchResult 获取照片非常慢,有很多照片

iOS 使用方向键导航 TableView