If I see a UIView
in Debug View Hierarchy
and I don't know where it comes from,
Is there a way to see where it has been programmatically created in code?
This question describes and explains the reverse case (you have the code of the view and you see where it is located in the view hierarchy).
How can I find where I (accidentally) created a view in my code using the code provided by the view in the Debug View Hierarchy
?
That is an extremely good question, but unfortunately the answer is no. There is nothing about the view debugger that tells you how any particular view came into existence.
A good way to track the creation of views might be to put symbolic breakpoints on their designated initializers:
You will break a lot, but each time you do you can look to see if this is the problematic view and then continue. Eventually, it will be! And now you can see who is calling the initializer.