ViewController from Xib to Storyboard

Discussion in 'iOS Programming' started by at0m87, Mar 3, 2012.

  1. at0m87 macrumors newbie

    Mar 2, 2012
    In my XIB Sample code, the file owner is TrainViewController and WritingViewController is added into the XIB as shown in the picture below. and the IBOUTLET "Sign" from TrainViewController is connected to WritingViewController. Note: i annotated wrongly on the picture should be TrainViewController instead of TrainingViewController.


    So in my Storyboard which i am trying to replicate the same code, i created two view controller scene which is TrainViewController as well as WritingViewController. I am unable to link the IBOUTLET "Sign" to WritingViewController as i believe they are not "link" like in the XIB sample code where the WritingViewController is in the same XIB as the TrainViewController.


    what should i do?
  2. brontosaurus, Mar 3, 2012
    Last edited: Mar 3, 2012

    brontosaurus macrumors newbie

    Mar 1, 2012
    Yakima, WA (no where USA)

    In storyboard, are you trying to connect a UI object in one view controller (scene) to another view controller (scene) using an outlet? If so, I think you might need to look into creating a segue instead.
  3. at0m87 thread starter macrumors newbie

    Mar 2, 2012
    in the XIB, there is a trainViewController which declared "IBOutlet writingViewController *sign" and this IBOutlet is connected to the writingViewController view controller in the same XIB.

    What i think it is actually doing is to create a link between the two controllers.

    in parts of the codes of the trainViewController.m
    [sign.signArray removeAllObjects];
    signArray, drawImage and writeTimer are all declared in the writingViewController.h

    to also note that UIImageView *drawImage is declared in writingViewController.h but it is physically on the the trainViewController's view controller.

    how should i achieve this same concept in the storyboard method. i know i can't connect the IBOutlet from trainViewController to writingViewController. segue? how should i do that?
  4. brontosaurus macrumors newbie

    Mar 1, 2012
    Yakima, WA (no where USA)
    I'm trying to learn this stuff too.

    Segues are what define the transitions between view controllers (or scenes). You already have a couple of segues in your app already. Visually, they are represented by arrows between your scenes in the storyboard canvas.

    You create segues in storyboard by control-dragging from a UI object or a view controller to another view controller. Then in the pop-up that appears, you choose the type of segue. For a navigation hierarchy, for example, you would choose a push segue.

    As far as the outlet business goes, don't declare sign as an outlet; instead just declare it as a regular property:
    @property (strong, nonatomic) writingViewController *sign;

    How is the train view controller related to the rest of your app? Is the train view controller already a part of a navigation hierarchy? And how do you want the train view controller to present the writing view controller?

Share This Page