gpt4 book ai didi

ios - 为编程 UINavigationController 制作文件?

转载 作者:行者123 更新时间:2023-11-29 02:50:43 25 4
gpt4 key购买 nike

我制作了一个 UINavigationController,我让它工作得很好,但我现在需要使用它。我需要与 Controller 同步的文件。我以编程方式构建所有内容。

如何设置这些文件?

AppDelegate.h:

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *navigationController;
@property (strong, nonatomic) UIViewController *rvc;

AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.navigationController = [[UINavigationController alloc] init];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0/255 green:126/255 blue:233/255 alpha:1]];
[self.window addSubview:[self.navigationController view]];

[self.navigationController pushViewController:self.rvc animated:YES];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

最佳答案

创建一个 UIViewController 子类并使 rvc 属性具有该类的类型。之后你可以在创建的子类中编写你的逻辑。

正确的 didFinishLaunchingWithOptions 实现:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.navigationController = [[UINavigationController alloc] init];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0/255 green:126/255 blue:233/255 alpha:1]];
self.window.rootViewController = self.navigationController;

self.rvc = [[<your_class_name> alloc] init];
[self.navigationController pushViewController:self.rvc animated:YES];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

关于ios - 为编程 UINavigationController 制作文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24576302/

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