MainView.xib 不存在于选项卡栏应用程序中

发布于 2024-12-17 12:01:05 字数 258 浏览 0 评论 0原文

我是标签栏应用程序的新手,我发现所有教程都需要更改 MainView.xib 中的某些内容,但是当我创建新的标签栏应用程序(在 Xcode 4 中)时,没有 MainView.xib。唯一的有:

FirstViewController_iPhone.xib
首先...iPad.xib
第二...iPhone.xib
其次...iPad.xib

它应该在那里但它丢失了,或者您能给我指出一个不需要 Interface Builder 的教程吗?

I'm new to tab bar applications and all the tutorials I find need to change something in MainView.xib, but when I create a new tab bar app (in Xcode 4), there is no MainView.xib. The only ones there are:

FirstViewController_iPhone.xib
First...iPad.xib
Second...iPhone.xib
Second...iPad.xib

Is it supposed to be there and it's missing, or could you point me to a tutorial that does not require Interface Builder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人九事 2024-12-24 12:01:05

在 iOS 的最近几个版本中,设置主界面的方法发生了变化。您可以在项目设置或代码中设置它,就像默认情况下所做的那样:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    UIViewController *viewController1, *viewController2;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPhone" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPhone" bundle:nil] autorelease];
    } else {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPad" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPad" bundle:nil] autorelease];
    }
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;

}

由于它是一个选项卡栏应用程序,因此该应用程序在代码中创建一个 UITabBarController,然后将其视图控制器设置为 FirstViewController 和 SecondViewController 类的实例。

如果你想跟随本书,你可以删除这个方法的内容并创建一个名为MainWindow.xib的xib,其中有一个选项卡栏控制器和两个子级,即前面提到的实例。单击您的目标设置,然后在“摘要”页面上的iPhone / iPod 部署信息下,您应该会看到一个标记为主界面的下拉菜单。将其值设置为 MainWindow.xib 以使其在应用程序运行时加载。

The method of setting the Main Interface has changed over the last few revisions of iOS. You can set it in your project settings or in code, as is done by default:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    UIViewController *viewController1, *viewController2;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPhone" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPhone" bundle:nil] autorelease];
    } else {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPad" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPad" bundle:nil] autorelease];
    }
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;

}

Since it's a tab bar application, the app creates a UITabBarController in code, then sets its view controllers to instances of the FirstViewController and SecondViewController classes.

If you want to follow the book, uou can delete the contents of this method and create a xib called MainWindow.xib, with a tab bar controller in it and two children, the aforementioned instances. Click on your target settings, and on the Summary page, under iPhone / iPod Deployment Info you should see a drop down menu labelled Main Interface. Set its value to MainWindow.xib to have it load when the app runs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文