gpt4 book ai didi

ios - 在没有 Storyboard的情况下更改 View Controller

转载 作者:行者123 更新时间:2023-11-29 10:40:33 26 4
gpt4 key购买 nike

我正在尝试更改 View ,但出于无关紧要的原因,我希望必须通过代码而不是 Storyboard来完成,我发现了这段代码:

[[self ] presentModalViewController:[self destinationViewController] animated:NO];

问题是我不知道为 presentModalViewController 或 destinationViewController 添加什么。有没有什么方法可以弄清楚我的 View 叫什么,以便我可以将它们放入?

最佳答案

在顶部你应该有

#import "NameOfViewController.h"

后来

UIViewController *destinationViewController = [[NameOfViewController alloc] init];
[self presentViewController:destinationViewController animated:NO completion:nil];

使用 presentViewController 而不是 presentModalViewController 因为后一种方法已被弃用。我希望这对你有用。

关于ios - 在没有 Storyboard的情况下更改 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24769957/

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