gpt4 book ai didi

iphone - 如何在代码中将 UINavigationController 添加到 View ?

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

view1 = [[View1 alloc] init];   //Create the first view
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:view1];
navigationController1.navigationBar.tintColor =[UIColor blackColor];

View1继承自UIViewController。所以我创建一个 *view1,然后创建一个 UINavigationController,调用 *navigationController1。我如何将两者联系在一起?非常感谢

最佳答案

将 View Controller 与导航 Controller 链接的方法是将 View Controller 推送到导航堆栈上。例如:

UIViewController * yourViewController = [[UIViewController alloc] init];
UINavigationController * navigation = [[UINavigationController alloc] init];
[navigation pushViewController:yourViewController animated:NO];
[yourViewController release]

最后释放 View Controller ,因为导航 Controller 保留了它。

关于iphone - 如何在代码中将 UINavigationController 添加到 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2278627/

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