Why is UIPopoverController not a subclass of UIViewController?

Can you come up with specific reasons why Apple decided to implement the UIPopoverController as a simple subclass of NSObject? For me, subclassing the UIViewController will make much more sense to implement the proper localization of the UIViewController.

But maybe there are reasons that I didn’t think about, why Apple bright engineers made their choice?

+6
source share
2 answers

I guess this is because, like UIAlertView, it is represented in the new UIWindow interface, so the windowLevel property ensures that it is presented throughout the content.

Regardless of whether it is in the new UIWindow, as far as the restriction on viewing the controller is concerned, you should not have problems using the complex container containers of the parent-child controller in the view controllers present in the UIPopoverController. I have view controllers with at least three placement levels in Pillboxie for some of the popovers without any problems.

UPDATE: I checked the hierarchy by registering the classes of the first three levels of the view hierarchy in the project example, and it looks like this when visibility is visible (my root view controller had two UIButtons):

WINDOW:

_SUBVIEW CLASS: UIView

___ SUBSUBVIEW CLASS: UIRoundedRectButton

_ _SUBSUBSUBVIEW CLASS: UIButtonLabel

___ SUBSUBVIEW CLASS: UIRoundedRectButton

_ _SUBSUBSUBVIEW CLASS: UIButtonLabel

_SUBVIEW CLASS: UIDimmingView

___ SUBSUBVIEW CLASS: _UIPopoverView

_ _SUBSUBSUBVIEW CLASS: _UIPopoverStandardChromeView

_ _SUBSUBSUBVIEW CLASS: UIView

The Apple documentation states that the root view controller view in UIWindow should not have any views for sisters managed by other view managers, as these child view view managers will not receive rotation events (see here , second brand).

So, if Apple made the UIPopoverController a subclass of the UIViewController, it would have to add it as a child / subclass of the rootViewController hierarchy. But what if the root view controller (which is your code anyway) decides to present a view that interferes with the view hierarchy of the UIPopoverController? Instead of letting us hack it, it seems that Apple decided to completely control the UIPopoverController view, but in such a way that they did not have to throw themselves an exception to the UIWindow policy that does not support view-view-view-view.

+3
source

because UIPopoverController objects UIPopoverController not interact with the user, therefore it is not part of the View layer, your UIViewController is able to communicate with the user, UIPopoverController does not perform similar tasks within itself.

Quickly review the general definition of the controller:

The controller can send commands in the appropriate form to change the viewing of the presentation of the model (for example, by scrolling through a document). It can send model commands to update the model (for example, editing a document).

it explains why it is not part of the View layer, I hope this helps.

0
source

Source: https://habr.com/ru/post/923031/


All Articles