Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6468215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:52:08+00:00 2026-05-25T05:52:08+00:00

I’m very new to iOS programming (Coming from Java / C++). I’m trying to

  • 0

I’m very new to iOS programming (Coming from Java / C++). I’m trying to set up an app with a TabBarController of which one tab should be a SplitView. I’ve done my research and I know that UISplitview will not work and everywhere people recommend using the MGSplitViewController. I’ve looked at the demo but I just can’t figure out how to use it without it beeing the app’s root view and can’t find any sample code that could help
So here is what I do with the classes from the demo in a separate UIViewController class that I afterwards add to the TabBarController: This is my class:

#import <UIKit/UIKit.h>
#import "MGSplitCornersView.h"
#import "RootViewController.h"
#import "DetailViewController.h"



@interface ChannelViewController : UIViewController {
    MGSplitViewController *splitViewController;
    RootViewController *rootViewController;
    DetailViewController *detailViewController;

}

@property (nonatomic, retain) MGSplitViewController *splitViewController;
@property (nonatomic, retain) RootViewController *rootViewController;
@property (nonatomic, retain) DetailViewController *detailViewController;


@end

And this is my desperate try to set it up

- (id)initWithTabBar
{
    self = [super init];

    //this is the label on the tab button itself
    self.title = @"SplitView";

    //use whatever image you want and add it to your project
    //self.tabBarItem.image = [UIImage imageNamed:@"name_gray.png"];

    // set the long name shown in the navigation bar at the top
    self.navigationItem.title=@"Nav Title";

    self.splitViewController = [[MGSplitViewController alloc] init];
    self.rootViewController = [[RootViewController alloc] init];
    self.detailViewController = [[DetailViewController alloc] init];

    [self.splitViewController setDetailViewController:detailViewController];
    [self.splitViewController setMasterViewController:rootViewController];

    [self.view addSubview:splitViewController.view];

    [self.rootViewController performSelector:@selector(selectFirstRow) withObject:nil afterDelay:0];
    [self.detailViewController performSelector:@selector(configureView) withObject:nil afterDelay:0];

    if (NO) { // whether to allow dragging the divider to move the split.
    splitViewController.splitWidth = 15.0; // make it wide enough to actually drag!
    splitViewController.allowsDraggingDivider = YES;
    }

    return self;
}

I guess I’m doing something wrong with delegates? Or do I have something else mixed up?
Is the demo doing things in the IB that I can’t see in the code?
I get the split view but no content and especially no navigation bar with the buttons the demo comes with.

I’d be very thankful for hints or sample code!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:52:09+00:00Added an answer on May 25, 2026 at 5:52 am

    Ok manny, here we go. This is my working code for the interface:

    #import <UIKit/UIKit.h>
    #import "MGSplitViewController.h"
    #import "ecbView.h"
    #import "ecbCalc.h"
    
    @interface splitMain : MGSplitViewController <UIPopoverControllerDelegate,
                                                  MGSplitViewControllerDelegate>
    {
        IBOutlet UIPopoverController*       popoverController;
        IBOutlet UINavigationController*    naviController;
        IBOutlet ecbCalc*                   viewCalcLeft;
        IBOutlet ecbView*                   euroRatesRight;
                 UIBarButtonItem*           savedButtonItem;
                 BOOL                       keepMasterInPortraitMode;
                 BOOL                       memoryWasDropped;
                 BOOL                       viewLoaded;
    }
    
    @property (nonatomic, retain) UIPopoverController* popoverController;
    @property (nonatomic, retain) UINavigationController* naviController;
    @property (nonatomic, retain) ecbCalc* viewCalcLeft;
    @property (nonatomic, retain) ecbView* euroRatesRight;
    @property (nonatomic, retain) UIBarButtonItem* savedButtonItem;
    @property (nonatomic, readonly) BOOL keepMasterInPortraitMode;
    @property (nonatomic, readonly) BOOL memoryWasDropped;
    @property (nonatomic, readonly) BOOL viewLoaded;
    
    - (void)dismissPopoverController: (BOOL)animated;
    - (void)settingsChanged;
    
    @end
    

    and here excerpts from implementation file:

    - (id)initWithCoder:(NSCoder *)aDecoder
    {
        if ((self = [super initWithCoder:aDecoder]))
        {
            // my initialization...
        }
    
        return self;
    }
    
    // Implement loadView to create a view hierarchy programmatically, without using a nib.
    - (void)loadView
    {
        CGRect  rectFrame = CGRectMake(0.0, 20.0, 768.0, 1004.0 - 48.0);    // being above a tab bar!
    
        viewLoaded     = NO;
        self.view      = [[UIView alloc] initWithFrame:rectFrame];
        viewCalcLeft   = [[ecbCalc alloc] initWithNibName:@"ecbCalc" bundle:nil];
        euroRatesRight = [[ecbView alloc] initWithNibName:@"ecbView-iPad" bundle:nil];
        naviController = [[UINavigationController alloc] initWithRootViewController:self.viewCalcLeft];
        naviController.navigationBar.barStyle = UIBarStyleBlack;
        naviController.title = nil;
        viewCalcLeft.title   = NSLocalizedString(@"BtnTitleCalc",  @"");
        viewCalcLeft.view.hidden = NO;
    
        NSUserDefaults* prefs = [NSUserDefaults standardUserDefaults];
    
        if ([prefs objectForKey:@"iPadAlwaysSplitTableView"] != nil)
            self.keepMasterInPortraitMode = [prefs boolForKey:@"iPadAlwaysSplitTableView"];
        else
            self.keepMasterInPortraitMode = YES;
    
        NSArray*    theViewControllers = [NSArray arrayWithObjects:self.naviController, self.euroRatesRight, nil];
    
        [self setViewControllers:theViewControllers];
        [self setDelegate:self];
        [self setShowsMasterInPortrait:keepMasterInPortraitMode];
    }
    
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad
    {
        // protection because this one is called twice
        if (viewLoaded)
            return;
    
        [super viewDidLoad];
    
        if (memoryWasDropped)
        {
            if (!self.keepMasterInPortraitMode && UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
            {
                // recreate popover controller
                self.popoverController = [[UIPopoverController alloc] initWithContentViewController:self.viewCalcLeft];
            }
        }
    
        viewLoaded = YES;
    }
    
    - (void)didReceiveMemoryWarning
    {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
        memoryWasDropped = YES;
    
        // Release any cached data, images, etc. that aren't in use.
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
        [self dismissPopoverController:NO];
    
        self.popoverController = nil;
        self.naviController    = nil;
        self.viewCalcLeft      = nil;
        self.euroRatesRight    = nil;
        viewLoaded = NO;
    }
    

    My MainWindow.xib has a UITabBarController and the button for splitMain is configured for this class but with an empty xib entry. So creation has to go via loadView. Maybe I could have done the viewDidLoad stuff within loadView … but so I had to protect viewDidLoad from being called twice. That happens in loadView as soon as the view is instantiated from MGSplitViewController class because the initWithCoder there is calling [self setup]. In that function the frame rect is calculated with self.view.bounds so that viewDidLoad is called again because the view doesn’t exist yet. Maybe one could implement a workaround within MGSplitViewController.m but I was too lazy doing that.

    To get this working on a tab bar controller please make sure you commit most of the changes that are published on the MGSplitViewController’s git page. Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.