kodeco.com Forums

iOS 9 Storyboards Tutorial: What’s New in Storyboards?

Storyboards have loads of cool new features in iOS 9 — learn all about them in this iOS 9 storyboards tutorial.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1539-ios-9-storyboards-tutorial-what-s-new-in-storyboards

I’ve downloaded completed project for storyboard in iOS 9. I’m using Xcode 7.2. When the prepped app is built it shows an error ‘Expected separator etc.’

Below is screenshot for error.
Please reply ASAP.

The project has been updated for Xcode 7.3.

For 7.2 you just make the selector a string.

So here it would be action: "checkMarkTapped:". The : at the end of the string is important - it indicates that there is a parameter.

If you would like a further explanation of selector, there’s a good one on stackoverflow:

Thanks… It worked!!

1 Like

Do you know if there is a way of unwinding from a scene in a main storyboard to a storyboard reference ?

Here is a complex one:

I have a framework that has a storyboard with 3 views:

Splash - Logon - Menu

I am loading this framework storyboard in my app delegate and pass it a delegate to handle some interaction

My app storyboard has some scenes that are accessible from the menu

by example: if the user click on an item in the menu (remember the menu is in a separate framework) but I use a delegate to handle the button click and present the associated view controller

I could call a dismiss view controller to return to the menu or a normal navigation pop, but I can’t use the unwind (even if I define an unwind segue in the menu controller)

it looks like storyboard reference are a great way of navigation forward but not backward

hope it’s clear


I don’t really understand, I’m afraid.

I can create a main storyboard with a menu. It has a storyboard reference to another storyboard. I can ctrl-drag from the menu button to the storyboard reference to make a connection that will automatically load the other controller as a modal.

I then create an unwind method in the menu view controller.

In the other storyboard, I can embed the view controller into a navigation controller and create a Done button. I can then ctrl-drag from the Done button to Exit and connect up the menu’s unwind method.

I attach a simple project.

TestRef.zip (24.8 KB)

Hi Caroline, thanks! Ok let me explain it to you

you have to create 2 Xcode projects

Project 1 - Dynamic Framework

Add a storyboard
Create 1 view and link it to a view controller class
Add an unwind segue to the class

Project 2 - Single view application

Add a view controller or use the default one
Add a storyboard reference

Now there are 2 ways of importing project 1 into project 2

you can drag it into project one
or you can import it using the embed library

after you need to go in project 2, and in your storyboard reference specify the name of the storyboard and bundle identifier of project 1

after in project 2, in the storyboard, if you take your view controller drag it to the exit you will see the unwind segue from the storyboard refrence

that is only true if you drag the project 2 inside project 1

if you link it using the embed library it does not work and I don’t know why

Caroline, I made a quick video to explain it, hope it helps

you will see first I will import the framework using drag and drop and I can see my unwind segue

after I will import the framework the standard way using embed library and I can’t see the unwind segue

here is the 2 projects

FrameworkTest.zip (21.2 KB)
UseFramework.zip (48.1 KB)

@giguerea - Edit: see following post for a possible solution. :smiley:

I’ve played around with it, and I can’t see how to make it work either.

Your video was very helpful in describing the problem :slight_smile:.

If you were to create a VC on the UseFramework storyboard and wanted to use ViewControllerA as the VC, then you have to specify the module otherwise IB won’t find it at runtime.

So I am surmising that Interface Builder does not know about the module and therefore is not checking the IBAction unwinds there.

This Apple technical note says

Like IBActions and IBOutlets, unwind actions do not need to be declared in your class header file. The exception is if you are writing a framework and want clients of your framework to be able to create an unwind segue that targets your action

But your IBAction is declared in FrameworkTest-Swift.h so that shouldn’t be a problem.

I would suggest taking this up either on the Apple Developer forum or stackoverflow.

I’m sorry I can’t sort out your problem :disappointed:.

@giguerea - I suddenly had another thought. That if I made an Objective C header of ViewControllerA in FrameworkTest and linked with objc flags it might work.

And it seems to!

1 - in FrameworkTest:

create a new header file ViewControllerA.h containing:

#ifndef ViewControllerA_h
#define ViewControllerA_h

#endif /* ViewControllerA_h */

@interface ViewControllerA : UIViewController {
-(IBAction) unwindToViewA:(UIStoryboardSegue *) segue;

In Target Membership (File Inspector), tick FrameworkTest and make it Public instead of Project.

2 - In FrameworkTest.h add this line:

#import <FrameworkTest/ViewControllerA.h>

3 - In UseFramework add this to Other Linker Flags in Build Settings:


(Actually I’m not sure that’s needed - try it without this step.)

The unwind segue should now show up!

(I also had to embed FrameworkTest again as it didn’t seem to be embedded in UseFramework.)

Caroline, I am so happy that you found it, it works!

and I don’t need to add the flag -Objc to my build settings

Last question, you probably have notice it

when you add your storyboard reference, if you have drag the framework in your project, in the storyboard reference dropdown list, you can see all your storyboard (the one in your app and the one in the framework)

but if you include your framework as an embedded library, you can still reference your framework storyboard in your app but it does not appears in the dropdown list of the storyboard reference? Strange

thanks again for your help, very appreciated


Thank you so much for this tutorial. I used it to expand/collapse rows in my tableview and it works great, except for the height of the notesView, which in your code is fixed to 128. I’ve been struggling with this for a few days now and I can’t figure out how to make it dynamic (since I need to show all the content when the row is tapped).

My UIView contains an UITextView, and I’m updating its attributedText field before adding the UIView to the StackView.

Then, in your code:
descriptionView.heightAnchor.constraintEqualToConstant(128).active = true

One of the many things I tried was replacing the 128 with the UITextView.intrinsicContentSize().height, but this value seems to be -1.0 all the time.

Any ideas on how I could accomplish a dynamic height for the added view?

Thank you very much in advance!

I have embedded a project within another project, added it as a target dependency. I want to have a button in the main project’s storyboard to instantiate a view controller from the embedded bundle, I’ve added a segue from the button to a storyboard reference with all the properties set correctly, but in run time instead of searching for the storyboard in the bundle I declared(as bundle identifier) it searches in the main bundle and can’t find it so the application crashes. Any suggestions?

That may all be too much for Interface Builder. Have you tried in code? You can set it all up in storyboards, but you can use

let vc = storyboard.instantiateViewControllerWithIdentifier("VC Name")

You’d also have to give the view controller a Storyboard Identifier in Interface Builder.

Yes I have, Actually I tried implementing it in code first since I didn’t know about storyboard references. Here’s my code:

@IBAction func clicked(sender: AnyObject) {
    let bundle = NSBundle(identifier: "com.domain.b")
    let storyBoard = UIStoryboard(name: "Main", bundle: bundle)
    let vc = storyBoard.instantiateViewControllerWithIdentifier("aVC")
    self.presentViewController(vc, animated: true, completion: {})

and I get the following error in runtime:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x7f8578cd34d0>) doesn't contain a view controller with identifier 'aVC''

more info on my problem:
my StackOverflow question

Beyond my knowledge, I’m afraid.

However, I would have thought that it’s cleaner to make a framework. There’s a tutorial here to do that: https://www.raywenderlich.com/126365/ios-frameworks-tutorial

Hi, I can’t get the video running.
Is it gone? Can it come back?
Thank you.

@rvamerongen - what video? This tutorial doesn’t have a video as far as I remember.

hi, in the comments of the 8th of June.

Ah yes - @giguerea’s video. But that was just a video of a problem which was subsequently sorted out. I’m afraid I don’t remember what it was all about, but it wasn’t very relevant to this tutorial.