gpt4 book ai didi

iphone - 从 superView 获取特定类型 View 的所有元素

转载 作者:行者123 更新时间:2023-11-28 18:22:34 27 4
gpt4 key购买 nike

我有一个 UITableView

UITableView 包含

  1. UITextView
  2. UICollectionView
  3. UILabel

现在,我想从 superView 中获取所有 UILabel

怎么做?

最佳答案

您可以使用以下代码获取 TextView 的所有 subview :

for(UIView * subView in myTextView.subviews ) // here write Name of you TextView 
{
// Here You can Get all subViews of your TextView.
// But For Check subview is UILabel or not ? write following code also.

if([subView isKindOfClass:[UILabel class]]) // Check is SubView Class Is UILabel class
{
// You can write code here for your UILabel;
}
}

关于iphone - 从 superView 获取特定类型 View 的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17344112/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com