Positioning problem of navigation controller

Discussion in 'iOS Programming' started by contemascetti, Dec 30, 2010.

  1. contemascetti macrumors newbie

    Joined:
    Dec 30, 2010
    #1
    Hi. I have a small problem putting a navigation controller inside a splitview controller inside a tabbar controller. I do all the work programmatically without interface builder.
    The problem is that the navigation controller seems to place itself a bunch of pixels below its original supposed position. This problem only happens with navigation controller, i tried with tableviews and customized simple views and they fit correctly immediately beneath the ipad top bar.
    I include a screenshot of that:
    [​IMG]
    The code is the one below (tabbar and splitview are defined in the appdelegate, this is the viewcontroller placed on the left of the splitview):

    Code:
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    	
    	userKindTableViewController=[[UITableViewController alloc] init];
    	
    	navigationController=[[UINavigationController alloc] initWithRootViewController:userKindTableViewController];
    	
    	userKind=[[UITableView alloc] initWithFrame:navigationController.view.frame style:UITableViewStyleGrouped];
    	userKind.dataSource=self;
    	userKind.delegate=self;
    	[userKind reloadData];
    	
    	userKindTableViewController.tableView=userKind;
    	userKindTableViewController.title=@"Categorie utenti";
    	
    	self.view=navigationController.view;
    }
    Thank you!
     
  2. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    A simple solution might be to drag the Nav bar up higher than you want it in Interface Builder and then see if it lines up when you build and run.

    Nick
     
  3. contemascetti thread starter macrumors newbie

    Joined:
    Dec 30, 2010
    #3
    As I said i'm not using Interface Builder at all, partly because i need to make complex and frequent changes to the UI via code...
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You're not allowed to put split view controllers inside anything. They must always be the root.
     
  5. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #5
    You could however use somthing like MGSplitViewController which gives you a lot more flexibility over the native split view controller and has no such restrictions.

    http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad
     

Share This Page