我是 iOS 开发的新手,试图学习如何以编程方式创建和设置视图。
我正在尝试在 Obj-C 中快速声明
window?.rootViewController = UINavigationController(rootViewController : ViewController())
项目:单视图应用程序。试图链接默认的 Created ViewController.h
根据 Krunals Answer 我更新了代码,但导航控制器未显示在模拟器中
Cmd+单击控制器不会导航到 ViewController 文件
#import "AppDelegate.h"
#import "ViewController.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIScreen *screen=[[UIScreen alloc]init];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.makeKeyAndVisible;
ViewController *controller = [[ViewController alloc] init];
window.rootViewController = [[UINavigationController alloc] initWithRootViewController:controller] ;