代码之家  ›  专栏  ›  技术社区  ›  Sophtware

在iphone或ipad上遍历视图层次结构[复制]

  •  43
  • Sophtware  · 技术社区  · 15 年前

    有没有一个检查ios应用程序视图层次结构的gui工具?我在考虑webkit的web检查器或类似的工具。我希望调试布局问题,例如位置或大小错误的视图,或父视图中未正确包含子视图。目前,我不得不补充断言,测试这些不同的条件,或设置不同的背景颜色,在不同的看法,你可以想象,这是一个真正乏味的方式去做。

    我看了仪器 UI recorder ,但这只会记录和回放用户界面操作,而且无论如何,只适用于Mac应用程序。

    有更好的解决办法吗?

    0 回复  |  直到 6 年前
        1
  •  157
  •   jameshfisher    7 年前

    Xcode6现在已经内置了3D视图层次结构检查,比如Reveal应用程序和Spark Inspector。

    enter image description here

    在应用程序运行时单击“调试视图层次结构”按钮以暂停执行并在当前时刻检查视图。

    enter image description here

    更多信息 Apple's documentation .

        2
  •  259
  •   Pang Ajmal PraveeN    10 年前

    我不知道是否有一个gui视图检查工具,但是我在uiview上的调试方法上有些运气: -recursiveDescription

    如果您在调试器中暂停程序并将其输入到gdb(edit:也适用于lldb)

    po[[uiwindow keywindow]递归描述]

    您将得到整个视图层次结构的打印输出。您还可以对特定视图调用它,以获得该视图的视图层次结构的打印输出。

    浏览你从中得到的信息可能有点乏味,但事实证明它对我很有用。

    功劳归于 this blog post 它讨论了这种方法,并与 this helpful, but rather hard to find Apple tech note .

        3
  •  46
  •   livingtech    10 年前

    Reveal app screenshot

    奇怪的是,现在有了另一个选择, http://revealapp.com/ ,这是一个公开(免费)的测试版。如你所见,这是另一个视觉检查员。

    编辑2014-04-05:Reveal已脱离beta版,不再免费。不过,还有30天的庭审。

        4
  •  35
  •   Damian Kołakowski    12 年前

    这个问题已经过时了,但让我在这里介绍一下我开发的新工具: https://github.com/glock45/iOS-Hierarchy-Viewer enter image description here

        5
  •  17
  •   Ben Gotow Dmitry Nogin    11 年前

    enter image description here

    为了让这条线保持最新,我最近一直在玩 Spark Inspector . 不是免费的,但很好。

        6
  •  6
  •   AVEbrahimi    11 年前

    免费:只需在检查员中键入:

    po [[UIWindow keyWindow] recursiveDescription]
    

    商业广告: http://revealapp.com/ 我测试了revealapp的beta版本,它很好,但有漏洞。 另一个商业工具: http://sparkinspector.com/ 它是无缝工作的。

        7
  •  6
  •   Scott Bossak    9 年前

    这个 FLEX Debugger 提供一个应用内视图检查器,允许您修改正在运行的应用程序中的UI。它还记录网络请求。

    https://github.com/Flipboard/FLEX

    enter image description here

        8
  •  6
  •   Vlad    7 年前

    斯威夫特4。

    网间网操作系统 :

    extension UIView {
    
       // Prints results of internal Apple API method `recursiveDescription` to console.
       public func dump() {
          Swift.print(perform(Selector(("recursiveDescription"))))
       }
    }
    

    马科斯 :

    extension NSView {
    
       // Prints results of internal Apple API method `_subtreeDescription` to console.
       public func dump() {
          Swift.print(perform(Selector(("_subtreeDescription"))))
       }
    }
    

    用法(在调试器中): po myView.dump()

        9
  •  2
  •   Alok C    7 年前

    这将全部转储到调试窗口中(很难读取):( 在ios 10上工作,xcode 8.3.3

    po UIApplication.shared.keyWindow?.recursiveDescription()
    
        10
  •  0
  •   mph    8 年前

    批准的答案不再适用于我,使用 XCODE 8 和斯威夫特2.3。以下是对我有用的:

    po UIApplication.sharedApplication().keyWindow?.recursiveDescription()

        11
  •  0
  •   Albert Bori    6 年前

    对于swift/xcode 10,在调试控制台中输入:

    po yourView.value(forKey: "recursiveDescription")!
    

    它将为任何给定的 UIView .

    (信用: How to debug your view hierarchy using recursiveDescription )

    推荐文章