davidfuzju / SMBCustomRelationshipSegue

a simple implementation for custom relationship segue, enhance the custom container view controller in storyboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SMBCustomRelationshipSegue

[![CI Status](http://img.shields.io/travis/David Fu/SMBCustomRelationshipSegue.svg?style=flat)](https://travis-ci.org/David Fu/SMBCustomRelationshipSegue) Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

I've managed to make the custom container view controller set up relationship with its child view controllers looks as Apple’s UINavigtaionController or UITabbarController do in storyboard.

there are two examples in example folder:

  • sidemenu

    this example uses RESideMenu as a custom container view controller to show how to use SMBCustomRelationshipSegue make your storyboard continuous and meaningful

    RESideMenu is a very beautiful custom container view controller and here is the link

  • container

    this example is inspired by objc.io’s Custom Container View Controller Transitions and the repo is here. In that repo, the project implement the custom container view controller without any interface file, and I update it with SMBCustomRelationshipSegue, now the relationship between container view controller and child view controllers can be seen in storyboard

SMBCustomRelationshipSegue now supports one to one relationship(like UINavigationController’s rootViewController relationship segue) and one to many relationship (like UITabbarController’s viewControllers relationship segue). all you need to do are just two steps:

  1. subclass your view controller or UIViewController, overwrite the method:

     - (NSArray *)relationships
    

return the array of your property names which you want build a relationship, the lib will check it for you whether it is a one to one or one to many.

Note: if you overwrite the method awakeFromNib, you must call awakeFromNib super implementation or the SMBCustomRelationShipSegue would not work. RESideMenu's implementation overwrite the awakeFromNib and did not call the super implementation, I commit pull request, however I got no reply

  1. you need control drag your storyboard. link a custom relation ship segue between container view controller and child view controllers. and name the segue identifier .

    • one to one relationship should name with format

        relationship_{{propertyName}}"
      
    • one to many relationship should name with format

        relationship_{{propertyName}}_{{index}}
      

Note: you should ensure the index is continuous and started with 0

then it’s OK! followings are screenshot building relationships:

Requirements

iOS 7.0 and iOS 7.0 +

Installation

SMBCustomRelationshipSegue is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SMBCustomRelationshipSegue"

Author

David Fu, david.fu.zju.dev@gmail.com

License

SMBCustomRelationshipSegue is available under the MIT license. See the LICENSE file for more info.

About

a simple implementation for custom relationship segue, enhance the custom container view controller in storyboard

License:MIT License


Languages

Language:Objective-C 94.9%Language:Ruby 5.1%