Search code examples
iphoneuiviewuiviewcontrolleruiscrollviewuiscrollviewdelegate

How to use UIScrollView to switch between UIViews


How would I build multiple UIViews with multiple subviews and switch between them using a UIScrollView? I would appreciate anyone who can upload some code. I am a complete noob withe the iPhone.


Solution

  • I would "tile" the UIViews in the UIScrollView, then implement some kind of paging or "snap-to" mechanism. Listen on the appropriate notifications from the scroll view, then whenever scrolling finishes, just programmatically align the scroll view to the boundaries of one of your tiled UIViews.

    Alternately, look at using UIPageControl to implement this kind of behavior. The Weather app is a good example.