0

I'm wondering how I would be able to design my own custom tabs, that when clicked could show mutiple view on the screen

http://tinypic.com/r/2cxtjk7/5

I'm only currently able to find the bottom tabbed bar approach. Thanks for your help im quite new still so if you could explain in detail that would be great :)

1
  • I have done the same thing, but i am not sure how can i explain whole things, But i can help you if you have some issues while doing it. Commented Oct 15, 2013 at 9:47

2 Answers 2

1

Show Multiple views using custom tabs

   - (id)initWithNibName:(NSString *)nibNameOrNil 
               bundle:(NSBundle *)nibBundleOrNil
    {
    AccountViewController *accountViewController = [[AccountViewController alloc]
                        initWithNibName:@"AccountViewController" bundle:nil];
    MoreViewController *moreViewController = [[MoreViewController alloc]
                        initWithNibName:@"MoreViewController" bundle:nil];
    BarTabViewController *barTabViewController = [[BarTabViewController alloc]
                        initWithNibName:@"BarTabViewController" bundle:nil];
    LocationsViewController *locationsViewController = [[LocationsViewController alloc]
                        initWithNibName:@"LocationsViewController" bundle:nil];

    self.viewControllers = [NSArray arrayWithObjects:locationsViewController, accountViewController,
                            barTabViewController, moreViewController, nil];

    [self.view addSubview:locationsViewController.view];
    self.selectedController = locationsViewController;
    self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.selectedIndex = 0;

self.tabBarController.viewControllers = [NSArray arrayWithObjects:locationsViewController, accountViewController,
                    barTabViewController, moreViewController, nil];
self.tabBarController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:delegate.tabBarController animated:YES];
        return self;
    }

Like I said, this will display the selected controller properly, however when the app launches and I try to switch views with the tab bar, the subview just become grey... The following is the code to switch items:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if (item == locationsTabBarItem) {
        UIViewController *locationsController = [viewControllers objectAtIndex:0];
        [self.selectedController.view removeFromSuperview];
        [self.view addSubview:locationsController.view];
        self.selectedController = locationsController;
    }
    else if (item == accountsTabBarItem) {
        UIViewController *accountsController = [viewControllers objectAtIndex:1];
        [self.selectedController.view removeFromSuperview];
        [self.view addSubview:accountsController.view];
        self.selectedController = accountsController;
    }
    else if (item == barTabTabBarItem) {
        UIViewController *barTabController = [viewControllers objectAtIndex:2];
        [self.selectedController.view removeFromSuperview];
        [self.view addSubview:barTabController.view];
        self.selectedController = barTabController;
    }
    else {
        UIViewController *moreController = [viewControllers objectAtIndex:3];
        [self.selectedController.view removeFromSuperview];
        [self.view addSubview:moreController.view];
        self.selectedController = moreController;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

I added thing in view did load in the end here:

PatientDetailsViewController *patientDetailsView = [[PatientDetailsViewController alloc] initWithNibName:@"PatientDetailsViewController" bundle:nil]; [self addChildViewController:patientDetailsView]; [self.patientDetailsView addSubview:patientDetailsView.view]; [self.patientDetailsView setClipsToBounds:YES];

and then animated its opening with a button by adjusted the view frame size with an animation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.