如何在Xcode/iOS中设置UIView的标识符以调试自动布局? [英] How to set the Identifier of a UIView in Xcode/iOS for debugging auto layout?

查看:163
本文介绍了如何在Xcode/iOS中设置UIView的标识符以调试自动布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆