OGeek|极客世界-中国程序员成长平台

标题: ios - 以编程方式从 UIViewController 重定向到另一个 UIViewController [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:56
标题: ios - 以编程方式从 UIViewController 重定向到另一个 UIViewController

你能帮忙从一个 UIViewController 重定向到另一个吗?我有 2 个 UIViewController(ViewController 和 OverViewController)。我不知道如何从 ViewController 重定向到 OverViewController。我试过 [self performSegueWithIdentifier"OverViewController"sender:nil];

但它只显示错误 Receiver () 没有带有标识符“OverViewController”的segue 我将 Storyboard id 设置为 OverViewController

enter image description here



Best Answer-推荐答案


它对我有用。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName"Main" bundle:nil];
UIViewController *viewController = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier"OverViewController"];
[self presentViewController:viewController animated:YES completion:nil];

关于ios - 以编程方式从 UIViewController 重定向到另一个 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26955133/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4