Search code examples
objective-ciphoneuiscrollviewiphone-sdk-3.0

Objective-C : UIScrollView manual paging


I want to use the scrollview as something like a picker in horizontal mode. The scrollview holds up to seven subviews. Each subview represents a value. Always three views are visible and the one in the middle is the selected one.

Scrollview visible at start:

__ | V1 | V2

Scrollview set to view/value two:

V1 | V2 | V3

Scrollview set to last value:

V2 | V3 | __

The real problem I have got is the "pagingEnabled" flag. If pagingEnabled is set to YES the scrollview pages always three subviews/values instead of only one. If pagingEnabled is set to NO the scrollview does not clinch.

Is there a nice solution for my problem?

Thanks a lot, Dan ;)


Solution

  • Change the frame of the scrollview to be as if it were only displaying the middle view (i.e. a third of its original width, and offset by the same amount), but then set its clipsToBounds property to NO.