简体   繁体   中英

Xcode Tabbed Application - Adding New Tab view

I'm working with Xcode 4.2. I started to work with Tabbed Application and now I want to add 3rd and 4th Tabbed to story board on my application. How Can I add it? I try to use it but I cannot. :( I didn't get good tutorials for it.

Does anyone have any idea how to do this?

I went through this link , but I need to add 2 more Tabbed views to first view.

Update:

Just go and create Tabbed Application and they try to add one or two more tab view. I'm still trying it. But I can't.

Just add two more view controllers to your project, and then control drag from the tab bar controller to the view controllers to make segues to them. Make sure you select "Relationship-viewControllers" when the list pops up. Tabs will automatically be added.

You have to go to the menu and click on "New File", then Objective-C class, and finally make sure to select UIViewController subclass. Name it and then it will add the .h and .m files. Now in your storyboard make sure to change the class of each tab to the name of your file. That's it.

For those who are visual learners:

Create a new Tabbed Application project

在此输入图像描述

Which will give you a storyboard like this:

在此输入图像描述

Add new View Controller

在此输入图像描述

Add Tab Bar Item

在此输入图像描述

Connect to Tab View Controller

Control-drag from the Tab View Controller to the new View Controller to get the menu.

在此输入图像描述

That's it. Watch the following video for more details.

I am using Xcode 4.3.3 and I was able to add additional tabs by the following steps:

  1. Create a Tabbed Applications.
  2. Make sure Utilities is open. Pick View Controller from the Objects and drag and drop in *.storyboard.
  3. Click and hold control key. Click on Tab Controller and move the cursor to the new View Controller that you have added. When you release the mouse button and control key, you will see a popover which reads 4 options: - Relationship - View Controller, Push, Modal and Custom.
  4. If you select Relationship - View Controller option, Xcode automatically adds another tab and connects the Tab Controller to the window that you added.

From this point onwards it is pretty simple to modify the text/pictures of the tab.

To programatically add a third view controller to a standard tabbed iOS application:

  1. Go to File -> New -> File , select Objective-C class, enter "ThirdViewController" for the class, select "UIViewController" under the subclass of option. Check "With XIB for user interface."

  2. Go to the new XIB and add a label or other objects of your choice.

  3. In AppDelegate.m import your new class by adding #import "ThirdViewController.h" to the file imports.

  4. Still in AppDelegate.m, in the didFinishLaunchingWithOptions method create a UIViewController object for the third view (follow the format for the first two), and add the third view controller to the tabbarcontroller two lines below: self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil]; .

  5. Save and run your project.

The didFinishLaunchingWithOptions method should look like this when finished:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    UIViewController *viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

不是你问的,但是在创建一个新的应用程序时,你可以创建你想要从一个标签栏控制器访问的所有视图控制器,然后选择它们并从中选择“嵌入...标签栏控制器” '编辑'菜单。

If you click on the small header bar where you see the three icons:

在此输入图像描述

You can then copy and paste to not only generate a new ViewContoller in the StoryBoard, but capture all of the auto-layout you may have laboriously setup for that original ViewController . This is the ONLY way to capture the auto-layout settings that I know of.

Ultimately you can create some StoryBoard templates this way and have them just sitting around on disk. I have a "login entry" ViewController that I copy and paste this way for my apps for example.

And for the new folks, InterfaceBuilder breaks many of the object drawing app paradigms and is inconsistent within itself. Objects inside a view controller can be clicked and drug as expected; have polygon handles for resizing, etc as expected. ViewControllers do not respond to a click-n-drag. Instead you must click-n-drag on that header thing to drag it.

What i understand , according to this i give a answer. There should be "Tab bar controller" When u extract this "tab bar controller" u will find Navigation controller. Just copy this and past into that Tab bar controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM