最佳答案
您可以检查该特定 View 中的 subview 数量:
if([theView.subviews count] == 0) {
// View does not contain subviews
}
如果父 View 中有多个 UIView,并且您希望找出哪些 View 为空,则循环遍历父 subview 并检查每个 View 是否为空:
for(UIView * view in parentView.subviews) {
if([view isKindOfClass:[UIView class]] && [view.subviews count] == 0) {
// We found an empty UIView...
// Can you identify this view?
// If you need to do something with it, do it here.
}
}
关于ios - 如何检查UIView是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34542016/