获取UIScrollView的所有子视图

Gen*_*ike 4 objective-c uiscrollview ios

我需要获取一个包含所有子视图的数组UIScrollView.现在我正在使用

NSArray *subviews = [myScrollView subviews];
Run Code Online (Sandbox Code Playgroud)

但这似乎只返回代码运行时可见的子视图.我需要在UIScrollView的整个范围内的所有子视图,甚至是当前隐藏的那些(如在屏幕外).我怎么会这样?

从本质上讲,我正在寻找像a的contentSize属性之类的东西UIScrollView,除了只返回它的大小,UIScrollView如果它足够大以显示它的所有内容,我希望它返回内容本身.

编辑:我想我已经弄明白了:滚动视图这不起作用实际上是UITableView- 而且我认为它会消除掉我屏幕上的细胞,这就是为什么它们没有显示出来的原因.我打算做一些测试来证实.

iPa*_*tel 8

尝试使用以下代码为我工作.

for(UIView * subView in myScrollView.subviews ) // here write Name of you ScrollView.
{ 
     // Here You can Get all subViews of your myScrollView.
    // But For Check subview is specific UIClass such like label, button, textFiled etc.. write following code (here checking for example UILabel class).

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