Open qhhonx opened 4 years ago
My idea is that we can recursive to get parent viewcontroller from a UIView:
extension UIView {
func findViewController() -> UIViewController? {
if let nextResponder = self.next as? UIViewController {
return nextResponder
} else if let nextResponder = self.next as? UIView {
return nextResponder.findViewController()
} else {
return nil
}
}
}
But not sure if actually does Uber team are having UIView with RIB instead of UIViewController.
All viewable RIBs on the diagram above (Confirmation, Location Refinements, Menu) are UIViewController
based.
@qhhonx, Why would you like to use a UIView
vs. UIViewController
? A common misconception in iOS development is that UIViewController
needs to represent a single "screen" in application; however, this is not the case. UIViewController
can be composed of subsequent child UIViewController
s. These child UIViewControllers
can represent something as small as a button. Hence, why it seems why these examples stick to using UIViewController
s instead of UIView
s. What's the use case for just using a UIView
?
Some thoughts about this topic:
UIViewController
for each cell, disregarding the perf overhead?UIViewController
. I think I understand the why, the architecture pattern implementation of RIBs is fully agnostic of the platform but the architecture framework implementation is tied to the platform but it still makes me sad.UITabBarController
, UINavigationController
etc.UIViewController
wrapper just for the sake of making the view compatible with RIBs is a bit sad. I'm tempted to assume that SwiftUI should be a separate topic and that you will consider SwiftUI support more easily because it's possible to track things such as appearance for a SwiftUI view, which is not the case of a UIView.Before diving into the details of the RIBs internals, I'd like to turn the question around and ask what is the strong reason for RIBS to force the usage of UIViewController
? Is it because it needs to track things such as appearance, disappearance?
As documentation mentioned that a RIB can be viewable or viewless, it is found that viewable RIB must be associated with UIViewController. However, I think it is not possible and most viewable RIB should be UIView-based as RIBs framework encouraging us to make reusable and micro components.
As the below image shown, are those viewable RIBs (
Confirmation, Location Refinements, Menu
) UIViewController based?