I am currently trying to write some automated tests within instruments and am having a bit of an issue, is it possible to retrieve the number of views/panes in a scrollView so that I can say, if more than one view, scrollRight() for example?
Asked
Active
Viewed 2,344 times
1 Answers
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;
}
}

Greg Price
- 2,556
- 1
- 24
- 33
-
Just tried the above and am getting a parse error - have tried the following too with no luck:`int count = frontMostApp().mainWindow().scrollViews()[0].count; int count = frontMostApp().mainWindow().scrollViews()[0].subviews.count; int count = frontMostApp().mainWindow().scrollview.subviews.count;` – ChrisH May 17 '12 at 11:50
-
See above edit.. so you need to search in the mainWindow subview collection for you scrollview first – Greg Price May 17 '12 at 14:59
-
Thanks! got it working now - I ended up doing a count of title elements to give me the total number of views – ChrisH May 29 '12 at 14:53