SplitView inside MultiView

Discussion in 'iOS Programming' started by StarLion, Jan 3, 2011.

  1. StarLion macrumors newbie

    Joined:
    Jan 3, 2011
    #1
    (Yes, i'm a newb.)

    I'm reading through/using as a reference SamsTeachYourself iPad Application Development.

    I can create a SplitView, no problem.
    I can create a MultiView, no problem.
    I want to put my SplitView into the MultiView.
    Tried to drag/drop the files (renaming them, of course), and that crashed the program on launch.
    Tried to recreate the files in the Multiview app; that also causes the app to crash as soon as I click the button to produce the view.

    The kill log comes up as:
    Terminating app due to uncaught exception 'NSInternalInconsistancyException', reason: '- [UIViewController _loadViewFromNibNamed:bundle:] loaded the "InfoPanel" nib but the view outlet was not set.'

    Any idea what i'm doing wrong or how to go about it easier?
     
  2. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  4. StarLion thread starter macrumors newbie

    Joined:
    Jan 3, 2011
    #4
    A multiview (in Sams terminology, obviously), is a View Controller that loads other views.

    Code:
    @class CalcPanel;
    @class InfoPanel;
    
    @interface Multi2ViewController : UIViewController {
    	IBOutlet CalcPanel *Calc;
    	IBOutlet InfoPanel *Info;
    }
    
    @property (retain, nonatomic) CalcPanel *Calc;
    @property (retain, nonatomic) InfoPanel *Info;
    
    -(IBAction) loadCalc:(id)sender;
    -(IBAction) loadInfo:(id)sender;
    
    -(void) clearView;
    
    @end
    
    Code:
    -(IBAction) loadCalc:(id)sender {
    	[self clearView];
    	[self.view insertSubview:Calc.view atIndex:0];
    }
    
    -(void) clearView {
    	if(Calc.view.superview) {
    		[Calc.view removeFromSuperview];
    	} else {
    		[Info.view removeFromSuperview];
    	}
    }
     
  5. StarLion, Jan 3, 2011
    Last edited: Jan 3, 2011

    StarLion thread starter macrumors newbie

    Joined:
    Jan 3, 2011
    #5
    So i suppose the question is... how do I create a SplitView within this application, and load it using that coding? The InfoPanel.h and InfoPanel.m are only slight modifications of the standard Split View Based-Application template (and the modifications are only to establish the dataset, so nothing's been renamed or whatever), so the methods and such are already there and being built.

    EDIT: Or i suppose more generally; I want part of my program to be displayed in a Split View, and part of it (say if the user pushes a button on the toolbar) to be displayed as a normal view would.
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    The error you quote is self-explanatory. It says that a nib was loaded but the view controller's "view" outlet wasn't set. UIViewController has an outlet named "view" and you must connect that outlet to a UIView in the nib that is loaded using initWithNibName:

    There are several errors and misuse of naming conventions in the code you show, although it will probably mostly work. If that's directly from the book then you should probably look for another book. Also, Apple doesn't fully support third parties writing their own rootview controllers (unfortunately). There are some gotchas that will appear in many cases.
     

Share This Page