gpt4 book ai didi

iphone - 如何在Xcode 4.2中开发NavigationController而不使用storyboard和tableView?

转载 作者:行者123 更新时间:2023-12-03 20:52:31 25 4
gpt4 key购买 nike

我正在学习 Xcode,并作为实习生为 IOS 开发人员工作。我正在使用 Xcode 4.2 和 Lion 操作系统。我的目标操作系统是 ios 3+ 版本。有人告诉我,使用 Storyboard会给旧版本带来问题。所以我想在不使用 Storyboard 进行导航 Controller 的情况下进行开发。帮帮我吧,因为所有旧的教程根本没有帮助,因为由于 xcode 版本的变化,有很多不匹配的地方。请帮助我。

最佳答案

要创建导航 Controller ,请为您的项目模板选择单一 View 应用程序。在 AppDelegate.h 中,创建 UINavigationController 的实例。在 AppDelegate.m 文件中,执行以下操作:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
navigationController = [[UINavigationController alloc] initWithRootViewController:(UIViewController*)viewController];
[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}

这将使底座成为导航 Controller 。您可以使用

添加对此的其他 View
[self.navigationController pushViewController:newViewController animated:YES];

关于iphone - 如何在Xcode 4.2中开发NavigationController而不使用storyboard和tableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9973189/

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