RIBs icon indicating copy to clipboard operation
RIBs copied to clipboard

[iOS] is there a way to create a view-based rib?

Open JamesJunsungKim opened this issue 6 years ago • 6 comments

My title might not be obvious to some of you so here is my situation. I'd like to implement a view changes height dynamically based on its contents. I usually do it by overriding the intrinsicContentSize and autoresizingMask but since it's a view controller, I'm lost at how I should go around it.

And besides my situation, I feel there is a need to create a view-based rib since in some situations, we don't need a view controller's life cycle or view controller's aspects.

I was just wondering how you guys do it.

Thank you in advance!

JamesJunsungKim avatar Jun 02 '19 08:06 JamesJunsungKim

I use TextureGroup/Texture to handle view hierarchy, as the RIBs reference implementation is not well-suited for going past the VC stage.

ermik avatar Jun 07 '19 15:06 ermik

We have some RIBs where it's ViewController is embedded as sub view inside a Views/TableViewCell... RIB work very well with View Container and I just guest they implement Plugin by this way.

dangthaison91 avatar Jun 07 '19 15:06 dangthaison91

@dangthaison91 just implementing a view controller's view into another view is quite simple since it doesn't require the said view to override anything. my situation is a little bit different as the embedded view's properties should be overridden. I tried to tweak things here and there to change a view controller to a view but seems like I need to dig into the RIBs code base which I felt there must be a way they use to fulfill this need. that's why I brought it up.

JamesJunsungKim avatar Jun 10 '19 00:06 JamesJunsungKim

You can implement your custom view as a ViewController’s View object by overriding UIViewController:loadView. Then you effectively have a RIB for your custom view without needing to create something new.

On Jun 9, 2019, at 5:48 PM, James Kim [email protected] wrote:

@dangthaison91 just implementing a view controller's view into another view is quite simple since it doesn't require the said view to override anything. my situation is a little bit different as the embedded view's properties should be overridden. I tried to tweak things here and there to change a view controller to a view but seems like I need to dig into the RIBs code base which I felt there must be a way they use to fulfill this need. that's why I brought it up.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

JUSTINMKAUFMAN avatar Jun 10 '19 04:06 JUSTINMKAUFMAN

@JUSTINMKAUFMAN in my opinion, your approach is just a way around it. if you intend to just switch views by overriding functions, you don't necessarily need to choose loadView() to get this job done. it could be done in any other places.

And then, more importantly, I think you misunderstood my point. then how are you going to make the custom view that will be replaced with the original view?

my question was how to create a view-based RIBs.. not how to switch it with a custom view.

Hope it will get you on the right track. let me know if you have any ideas to resolve this situation.

JamesJunsungKim avatar Jun 12 '19 13:06 JamesJunsungKim