Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle viewControllers loaded from storyboard #13

Closed
enfoiro opened this issue Nov 13, 2015 · 4 comments
Closed

Handle viewControllers loaded from storyboard #13

enfoiro opened this issue Nov 13, 2015 · 4 comments

Comments

@enfoiro
Copy link
Contributor

enfoiro commented Nov 13, 2015

Hello,

The routeHandler does it's job very well, but the only problem I can see is that it does always instantiate view controllers with alloc, init.

When you have storyboards, you have to instantiate your view controllers through an instance of the storyboard, in order to have proper initialisation of IBOutlets, IBAction and all other custom configuration stuff done in the storyboard.
In my case, WAAppRouting doesn't work with most of my view controllers, but I don't want to implement another routeHandler because everything else does fit to my use-case.

I suggest to add an optional method in the routeTargetControllerProtocol where you can allow the controller to instantiate itself, from storyboard, xib, etc.
If the method is not present, we do the classic alloc, init.

I already have an implementation working, I could submit a PR if you like.

Thanks.

@ipodishima
Copy link
Contributor

Hi again

Yes, I'm not using storyboard at all, so was thinking to handle this later.
And you're correct that designing a route handler for this is a lot of work. However, I was hoping that Apple would release something with segue which keeps the context.
I'm worried about adding a protocol to instantiate the controller from the storyboard, without handling the segue.
I'm thinking that we should be able to trigger segue as well, correct? Again, not a user of storyboards, there might some mechanics I'm not used to.

However, having a way to instantiate a controller might be a good idea, to handle load from nib things for example. I was hoping some day to add it as well to the sugar syntax

@enfoiro
Copy link
Contributor Author

enfoiro commented Nov 17, 2015

I understand your point about segues.
I was thinking about my use-case and as I don't use so much segues, I totally forgot about them.

We can trigger them, but they need an identifier to be triggered, and there is no convention on naming them, so the handler will have to know each identifier for a route.

Well I think I'll stick to my first solution to be able to update my app soon, and I'll try to come up with a solution for segues, xibs, etc. when I have some time to think about it.

I'll close this issue and open a new one later with a more generic title to include both segues and xibs unless you already found a way to do it.

Cheers.

@enfoiro enfoiro closed this as completed Nov 17, 2015
@ndmeiri
Copy link

ndmeiri commented Dec 18, 2015

@ipodishima Would you please consider reopening this feature request? I think that the ability to load view controllers from storyboards is important. And having that ability will allow many other developers to use your already great library.

For my app, I can only use WAAppRouting to set up and show a root view controller. All my detail view controllers are loaded from a storyboard, and the app crashes if I try to route to a detail view controller because the IBOutlets are not initialized.

@mjjimenez
Copy link

I agree with @ndmeiri. Storyboard/Xib support is the only thing stopping me from using this this library so I hope you would reconsider. I agree with @enfoiro about adding an optional method in RouterTargetControllerProtocol for instantiating a view controller via storyboard.

When it comes to segues, a view controller can be instantiated from the storyboard without having to trigger any segues. It can exist independently from it's source segue and you can still trigger any additional segues coming from that view controller as long as it's loaded via UIStoryboard convenience methods -instantiateInitialViewController and -instantiateViewControllerWithIdentifier. Any context (I'm assuming any kind of state) provided by transitioning from an original segue can be provided from -reloadAppFromLinkRefresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants