gpt4 book ai didi

iphone - 如何以编程方式加载 UIViewController

转载 作者:行者123 更新时间:2023-12-03 19:06:11 26 4
gpt4 key购买 nike

我有以下代码,我想加载 UIViewController。如何初始化并加载 UIViewController。

- (void) applicationDidFinishLaunching:(UIApplication*)application
{

CC_DIRECTOR_INIT();

NSLog(@"applicationDidFinishLaunching");

MainViewController *controller = [[MainViewController alloc] init];





}

最佳答案

从您的委托(delegate)中,您可以执行此操作(假设您有 IBOutlet UIWindow *window):

[window addSubview:[controller view]];
[window makeKeyAndVisible];

加载 Controller 后,您可以推送其他 Controller (从 UIViewController):

controller = [[MainViewController alloc] init];
[[self navigationController] pushViewController:controller animated:YES];

这里是 UINavigationController.pushViewController 文档的链接

http://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html#//apple_ref/occ/instm/UINavigationController/pushViewController:animated :

关于iphone - 如何以编程方式加载 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4127683/

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