简体   繁体   English

如何在代码中找到 UIView 的创建位置 - swift - 以编程方式

[英]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.

相关问题 快速创建程序后如何在情节提要中链接UIButton - How to link UIButton in the storyboard after it has been created programmatically in swift 以编程方式将 class 分配给在 Storyboard (Swift) 中创建的 UIView - Programmatically assigning class to a UIView created in Storyboard (Swift) 如何在 Swift 中以编程方式移动 UIView - How to move a UIView programmatically in Swift 在另一个不能在Swift中工作的UIView的顶部以编程方式创建的UIView - UIView created programmatically at top of another UIView not working in Swift 我如何告诉我的UIView UIViewController中的按钮已被按下? (迅速) - How do i tell my UIView that the button in UIViewController has been pressed? (Swift) 在Swift中以编程方式创建视图时,如何创建UIView对象的副本并减小特定标签的字体大小? - How to create a copy of UIView objects, and decrease the font size of a particular label, where views are made programmatically, in Swift? 如何使用 Swift 以编程方式增加 UIView 的高度 - How to programmatically increase the height of UIView with Swift 如何在 swift 中以编程方式在 UIView 上调用手势点击 - How to call gesture tap on UIView programmatically in swift 如何使用Swift以编程方式移动UIView并放置新的UIView? - How to shift UIView's and put a new UIView programmatically with Swift? Swift UIView Opacity以编程方式 - Swift UIView Opacity Programmatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM