本文介绍了如何检查 iOS 中的视图层次结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可以检查 iOS 应用程序视图层次结构的 GUI 工具?我在考虑 Webkit 的网络检查器或类似工具.我希望调试布局问题,例如位置或大小错误的视图,或者子项未正确包含在其父项中.目前我必须添加断言来手动测试这些不同的条件,或者在不同的视图上设置不同的背景颜色,正如您想象的那样,这是一种非常乏味的方法.

Is there a GUI tool that inspects the view hierarchy of an iOS app? I'm thinking about Webkit's web inspector or similar tools. I'm looking to debug layout issues, like views having the wrong position or size, or a child not being properly contained in its parent. Currently I have to add asserts that test these various conditions by hand, or set different background colours on different views, and as you can imagine, that's a really tedious way to go about it.

我查看了 Instruments 的 UI 记录器,但它只能记录和回放 UI 操作,而且无论如何只能用于 Mac 应用程序.

I looked at Instruments's UI recorder, but that only records and plays back UI actions` and, in any case, works only for Mac apps.

有更好的解决方案吗?

推荐答案

Xcode 6 现在内置了 3D 视图层次结构检查,如 Reveal App 和 Spark Inspector.

Xcode 6 now has 3D view hierarchy inspection built in like Reveal App and Spark Inspector.

在您的应用运行时单击调试视图层次结构"按钮以暂停执行并检查当前时刻的视图.

Click on the "Debug View Hierarchy" button while your app is running to pause execution and inspect the views at the current moment.

更多信息请访问 Apple 的文档.

这篇关于如何检查 iOS 中的视图层次结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 01:07