Scrolling Controls
The iPhone handles scrolling in a very intuitive manner. The timing of animations and the touch and gesture recognition build muscle memory and acclimate users to the idea of UI elements moving on- and offscreen. Apple sets some precedents for the timing of scrolling, zooming, and panning, and developers who wish to provide a consistent user experience should build their visual transitions around those precedents.
You can use the UIScrollView
class to create
views that scroll horizontally, vertically, or both. Scrollviews respond
to touches, drags, and flick gestures. Dragging a finger across the screen
slowly scrolls the content in the scrolling view in parallel. Quickly
flicking across the screen will throw the content in the direction of the
swipe, and it will continue moving after the touch sequence has ended.
Adding a scrolling view to an application is no different from adding any
other view to the screen because UIScrollView
is a subclass of
UIView
. Developers can enable a bounce effect using a
property of the UIScrollView
instance called
bounces
.
The Photos application uses a scrolling view to display
full-screen photographs sequentially. Scrolling views can scroll
incrementally or in larger units that correspond to the width of the
screen, also known as paging. You can enable paging with
the pagingEnabled
attribute of
UIScrollView
.
The following example creates a basic
UIScrollView
subclass for displaying a sequence of full-screen images. Bouncing is enabled, ...
Get Programming the iPhone User Experience now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.