gpt4 book ai didi

iphone - 使用 Custom Segue 以编程方式导航到另一个 ViewController

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

Storyboard中有两个 View Controller 。我确实以编程方式成功地从第一个导航到第二个:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
YourViewController *yourViewController = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];
[self.navigationController pushViewController:yourViewController animated:YES];

我想使用我的 custom Segue 导航到其他页面而不是 pushViewController 而不使用界面构建器。

这是我的自定义 Segue,我可以轻松地与界面构建器一起使用:

@interface LeftToRightSegue : UIStoryboardSegue

如何以编程方式进行?

最佳答案

这是我的做法。我创建了我的 segue 子类,然后从我所在的 sourceViewController IE 调用它,初始化我的 destinationViewcontroller,然后将它们传递给我的自定义 segue 类。

YourViewController *yourViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"YOURStoryboardViewControllerID"];
CustomSegueClass *segue = [[CustomSegueClass alloc] initWithIdentifier:@"ANYid" source:self destination:yourViewController];
[segue perform ];

关于iphone - 使用 Custom Segue 以编程方式导航到另一个 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12992716/

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