How to get children of scrollable view?
I'm building a photo viewer, similar to the Photos app on iPhone, where you can swipe left and right through photos. To do it, I'm just adding an image view for each photo to a scrollable view, and hiding the paging control. However, when I change the orientation of the device, I need to go back in and change the width and height properties of each of the image views in the scrollable view so they fit properly on screen.
My problem is, I can't loop through the scrollable view's views. I've tried '.children' and '.views' and they both return a null error.
Anyone know how to get the views in a scrollable view?
2 Answers
-
Bill
I'd imagine you'd want to keep a scrollable view in a single context, so for this reason it is very easy to access specified objects at any time. Thus, you aren't subject to whether views or children properties are functioning in the core code or not.
Simply create an empty array at the top of your script, and push the objects that you want to resize to it. Then, in your change orientation event, you can simply iterate through this array, resetting the dimension properties as you see fit.
Hope this helps
-
Anyone come up with a good solution for this yet?
Can the scrollable tabs example in kitchen sink be modified to display photos?
~Brian