Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在(UIApplication.shared.delegate as!AppDelegate.)窗口中为视图的所有子视图设置辅助功能标识符?_Ios_Swift_Xcode - Fatal编程技术网

Ios 如何在(UIApplication.shared.delegate as!AppDelegate.)窗口中为视图的所有子视图设置辅助功能标识符?

Ios 如何在(UIApplication.shared.delegate as!AppDelegate.)窗口中为视图的所有子视图设置辅助功能标识符?,ios,swift,xcode,Ios,Swift,Xcode,我正在为所有屏幕创建共享警报。代码如下: let window: UIWindow = (UIApplication.shared.delegate as! AppDelegate).window! let view = UIView(frame: window.bounds) let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 21)) view.accessibilityIdentifier = "

我正在为所有屏幕创建共享警报。代码如下:

let window: UIWindow = (UIApplication.shared.delegate as! 
AppDelegate).window!
let view = UIView(frame: window.bounds)
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 
21))
view.accessibilityIdentifier = "view"
window.addsubview(view)
当我试图在XCode辅助功能标识符工具中标识视图辅助功能标识符时,我无法获取标识符名称

有人能帮忙吗?如何获取视图的标识符名称


提前感谢

据我所知,您也有问题窗口,因此获取并使用下面的第一个窗口:

let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
使用辅助功能标识符工具,您应该可以看到窗口的子元素,如下所示: