如何在Xcode/iOS中设置UIView的标识符以调试自动布局? [英] How to set the Identifier of a UIView in Xcode/iOS for debugging auto layout?
问题描述
在WWDC 2012(掌握自动布局的最佳实践)的演讲中,演示者说您可以在Xcode中设置UIView标识符来帮助调试自动布局:
During a talk from WWDC 2012 (Best Practices for Mastering Auto Layout), the presenter said that you can set a UIView identifier in Xcode to aid in debugging auto layout:
这似乎是一个好主意,但是在我的iOS项目的Xcode 4.5.1中,我看不到设置UIView的标识的方法.
This seems like a really good idea, but in Xcode 4.5.1 for my iOS project, there is no way that I can see to set the Identity of a UIView.
如何在Xcode 4.5.1中设置UIView的标识?如果在iOS项目中无法做到这一点,我如何获得相同的功能?
How can I set the Identity of a UIView in Xcode 4.5.1? If this isn't possible in iOS projects, how can I get the same functionality?
推荐答案
在UIView
上设置accessibilityIdentifier
可以解决问题.在Xcode 6.4和iOS 8.4上进行了测试.
Setting accessibilityIdentifier
on UIView
does the trick. Tested on Xcode 6.4, iOS 8.4.
这篇关于如何在Xcode/iOS中设置UIView的标识符以调试自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!