ViewController Graph By StoryBoard

Declaration: the methods used in this article apply to xcode 4.2 if not stated specially.

Create Master-Detail Graph With Master Being A Table

In order that certain cell can be displayed with content and can receive action to drill down to detail view controller,  configurations of master should conform to some rules such as:

  1. ViewController must be UITableViewContoller or its child. If ViewController is a subclass of UITableViewController, one should comment out data source methods so as to show the content created by storyboard, namelynumberOfSectionsInTableView:,tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath.
  2. TableView's content must be Static Cells rather than Dynamic Prototypes which is the default setting.
  3. ViewCell does't have content if its Style is set to Custom, Accessory cannot be None.

PS: Project created from Master-Detail template by XCode conforms to these rules by default.


Present model view controller and dismiss

Refer to Present/Dismiss Model View Controller

Use view controller from storyboard

Sometimes, we need to instantiate view controller in an existing storyboard created by others. By the following procedure can a view controller be loaded from storyboard.

UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:
                                @"StoryboardNameWithoutExtention" bundle:nil];

// use storyboard to instantiate view controller
// The initial view controller can be called in this way.
// One can call the counterpart instantiateViewControllerWithIdentifier: if the view controller is not the initial view controller in the storyboard.
// The view controller returned must be saved or else the application will crash.
self.rootViewController = [storyBoard instantiateInitialViewController];

// Add the view controller's view to its parent, here the view controller's view's parent is the window.
[self.window addSubview:[rootViewController view]];






你可能感兴趣的:(ViewController Graph By StoryBoard)