Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked November 23rd 2010 by Bill Labus
  • child
  • children
  • iphone
  • scrollable
  • view
  • views
0 Comments

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

    — answered November 23rd 2010 by Paul Dowsett
    permalink
    0 Comments
  • Anyone come up with a good solution for this yet?

    Can the scrollable tabs example in kitchen sink be modified to display photos?

    ~Brian

    — answered January 13th 2011 by Brian Dittmer
    permalink
    1 Comment
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.