views:

531

answers:

2

Hi Folks!

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 ;)

+1  A: 

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.

hatfinch
This is a nice solution. Thanks :D
Daniel
But wouldn't you still wish to show the user part of V1 and V3 while they are selecting V2? Didn't shrinking the width to 1/3 make it so that only 1 item was visible at a time? (I would think you would want 1/2 + 1 + 1/2 visible at once. No?
Susanna
Read the OP's post -- he wants 1 + 1 + 1 visible at once, not 1/2 + 1 + 1/2. And take a look at the documentation to see what setting `clipsToBounds` to NO achieves :)
hatfinch
A: 

But then the scrollview can be scrolled only within that frame. User will perceive that its a long wide scrollview but it can only receive touch within that specified frame.

I am having the same problem. I have a scrollview with many subviews in it, arranged horizontally but I want to page between each subview.

Any idea?

Thanks

KHAN