gpt4 book ai didi

ios - 在 iOS 中以编程方式创建 UINavigationController

转载 作者:可可西里 更新时间:2023-11-01 03:36:32 25 4
gpt4 key购买 nike

我是 iOS 新手。我想在我的应用程序中使用导航 Controller ,但我不知道该怎么做。那么任何人都可以指导我一步一步地在我的应用程序中创建导航。

最佳答案

appDelegate.h

@property (strong, nonatomic) UINavigationController *navController;

并在 appDelegate.m 中设置委托(delegate) UINavigationControllerDelegate 和合成对象现在,

appDelegate.m

您可以在didFinishLaunchingWithOptions 方法中设置导航 Controller

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
frstVwCntlr = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.frstVwCntlr];
self.window.rootViewController = self.navController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

在上面的代码中,您的 firstViewController 设置为 UINavigationController 并将 UINavigationController 添加到 UIWindow

self.window.rootViewController = self.navController

希望对你有帮助

关于ios - 在 iOS 中以编程方式创建 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981610/

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