没有用户界面文件创建与iOS项目



我正在开始iOS编程,并在XCode 4.2.1中创建了一个新项目。但是,我没有在我的项目中看到预期的.xib文件。我尝试添加一个新的。xib文件并在其上构建界面,但当我运行我的程序时,我在iPad模拟器上看到一个空白的屏幕。我错过什么了吗?谢谢。

您可以在appDelegate中替换此方法(如果需要,还可以替换xib的名称/去掉代码的通用方面)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
    } else {
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
    }
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

在创建新应用程序时从提供的模板中选择单个视图应用程序

最新更新