1

我在 ViewController 中遇到问题。我正在使用 xcode 4.3.3,试图实现 iPhone 5.1 应用程序。每次我写一些关于 ViewController 的代码时,它都会报告相同的错误:使用未声明的标识符“viewController”。如果我用类型声明它UIViewController,它会出现运行时错误。

有些代码是这样的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{   
    self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:viewController];
    // Override point for customization after application launch.
    return YES;
}

它在AppDelegate.m 文件中。

在 ios 4 和 5 中使用 viewController 有什么区别吗?

4

1 回答 1

1

您实际上不需要为此修改 AppDelegate。

留空:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

然后在你的故事板文件中选择你想成为第一个的视图控制器,并确保选择“是初始视图控制器”。

于 2012-07-18T22:46:18.373 回答