[英]How to find where UIView has been created in code - swift - Programmatically
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?如果我在Debug View Hierarchy
中看到UIView
并且我不知道它来自哪里,有没有办法查看它是在代码中以编程方式创建的?
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
?如何使用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.现在您可以看到谁在调用初始化程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.