出于好奇,如何使用for循环设置所有子视图的委托?
for case let i in (myTest.popoverPresentationController?.presentedViewController.view.subviews)!
{
//how do i set the delegate of i?
i.delegate = self
}
答案 0 :(得分:-1)
你可以试试这个:
if let subviews = myTest.popoverPresentationController?.presentedViewController.view.subviews {
for view in subviews {
if let customView = view as? CustomView {
customView.delegate = self
}
}
}