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.’
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
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.
@giguerea - Edit: see following post for a possible solution.
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 .
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.
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.
@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:
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
Hello!
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?
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?
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''
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.