gpt4 book ai didi

iphone - 所有 View 中的 ui 导航栏

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

在我的项目中,导航栏仅在第一个 View 中出现在 Root View (homeview)中,我想在所有 View 中启用导航栏?这是我的代码?我应该为此做什么更改

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
SecondViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController2];
self.window.rootViewController =navigationController;
[self.window addSubview:[navigationController view]];
[self.window makeKeyAndVisible];
return YES;
}

请帮我编码?

最佳答案

查看此link

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
navigationController =[[UINavigationController alloc] init];

UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[navigationController pushViewController:viewController2 animated:NO];

self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}

当您从 viewController2 导航到另一个 View 时,请执行 pushViewController 而不是其他 View (例如presentView)

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

关于iphone - 所有 View 中的 ui 导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12385052/

25 4 0