gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:13:49 26 4
gpt4 key购买 nike

我目前正在 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 animated:(BOOL)animated Doc .

还有许多其他方法可以完成您正在寻找的东西,您使用的是导航 Controller 吗?然后 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 就是你想要的。您也可以将该 Controller 的 View 作为 subview 添加到当前的 viewController。

关于objective-c - 如何以编程方式移动到另一个 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12272710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com