0

我目前正在尝试在仪器中编写一些自动化测试并且遇到了一些问题,是否可以检索 scrollView 中的视图/窗格的数量,以便我可以说,如果有多个视图,scrollRight()例子?

4

1 回答 1

1
int count = scrollview.subviews.count;

if ( count > 1 ) 
{
.....
}

??

EDIT:

You will need to get a reference to the view you are looking for. This will be done by iterating through your windows subview collection. In objective-C it would be something like this:

 NSInteger count = 0;
 for ( UIView *view in self.window.subviews )
 {
     if([view isKindOfClass:[UIScrollView class]])
     {
          count = (UIScrollView *) view.subviews.count;
     }

 }
于 2012-05-11T16:44:20.200 回答