Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Working With Scroll Views

Working With Scroll Views

Avatar for Ash Furrow

Ash Furrow

March 08, 2012
Tweet

More Decks by Ash Furrow

Other Decks in Programming

Transcript

  1. What is a scroll view? • Subclass of UIView •

    A view which scrolls • Sometimes zooms Tuesday, 8 May, 12
  2. What is a scroll view? • Subclass of UIView •

    A view which scrolls • Sometimes zooms UIView UIScrollView Tuesday, 8 May, 12
  3. OK, what does “scroll” mean? • A container view that

    lets its subviews move around • Maps • Home screen • Table view • Most things that move in iOS Tuesday, 8 May, 12
  4. How to UIScrollView • Create scroll view, either in xib

    or programmatically • Add subviews • ??? • Profit! Tuesday, 8 May, 12
  5. How to UIScrollView • Create scroll view, either in xib

    or programmatically • Add subviews • ??? • Profit! • ʵ Set contentSize Tuesday, 8 May, 12
  6. contentSize • Defines the scrollable region • CGSize • Large

    contentSize values don’t adversely affect performance Tuesday, 8 May, 12
  7. Scrolling • With Fingers! • Receive delegate callbacks (next slide)

    • Programmatically • to top • to new contentOffset • to new rectangle Tuesday, 8 May, 12
  8. Interesting Properties • delaysContentTouches • scrollview gesture recognizers • bounces

    • alwaysBouncesVertical • alwaysBouncesHorizontal • scroll indicators (inset & style) • pagingEnabled Tuesday, 8 May, 12
  9. Zooming • I am not an expert at zooming scroll

    views • Different approaches • Watch the WWDC videos Tuesday, 8 May, 12
  10. Performance • UIScrollView Scales with subviews • Not with contentSize

    • UIImage will kill your memory footprint Tuesday, 8 May, 12
  11. Subclassing vs Delegation • Subclassing can break MVC • Better

    for repeated behaviours • Delegation can get verbose • You’re writing Objective-C, live with it Tuesday, 8 May, 12