View hierarchy is also an important part of the responder chain. When we need to render the content in the window, the framework of the application will use it to detect the layer level of views and determine the part to be rendered, so as to avoid doing some useless work. This is very important.
Next, let’s look at the definition relationship of the three attributes of view in view hierarchy
1. Supervisor, parent view of view
2. Subviews, subviews of view
3. Window, including the window of view
The third window property is different between IOS and MAC.
In IOS, window is a view, but not in MAC.
In MAC, window has a single contentview, and all subviews are included in the contentview.
In IOS, window itself plays the role of content view, so all sub views are included in window.
In the process of development, there are some problems
1.ios attempt to present whose view is not in the window hierarchy
2.Warning: Attempt to present on whose view is not in the window hierarchy!
And so on. As long as there is a window hierarchy in it, it is caused by the poor understanding of viewhierarchy.
The above problem is that when the view of a controller is not added to the window, another controller is called present. This is equivalent to building a building. If the second floor is not finished, you can go to build the third floor directly. This is definitely not good.
the most direct solution to the above problem is to call present in the controller’s viewdidappearance. This ensures that the hierarchy of view hierarchy is not disordered.
Similar Posts:
- How to Solve Error: whose view is not in the window hierarchy
- iOS Presenting view controllers on detached view controllers is discouraged
- Odoo14 TypeError: Cannot read property ‘classList’ of undefined
- Error UIViewAlertForUnsatisfiableConstraints when using tableview in Xib
- When deploying Django project on centos7, there will be an error of importerror: cannot import name middlewaremin
- How to Solve Critical dependency: the request of a dependency is an expression?
- What’s the difference between die() and exit() in PHP?
- You have not completed the merge: You have not concluded your merge (MERGE_HEAD exists)
- Block Wild Pointer crash: Thread 1:EXC_BAD_ACCESS(code=1,address=0x10)