开发者

Recreate UIPickerView with just one row showing

开发者 https://www.devze.com 2023-03-13 07:04 出处:网络
I need a \"PickerView\", that behaves like开发者_开发百科 a normal UIPickerView, but only shows one row of data and has a custom design.

I need a "PickerView", that behaves like开发者_开发百科 a normal UIPickerView, but only shows one row of data and has a custom design.

Something like you see in the image, showing the transition from subview 1 to subview 2. After the user lifts his finger and after the scrolling stops, only one subview will be shown:

IMAGE

So basically a scrollview which:

  • is endless in both, positive and negative directions by showing the same entries over and over

  • uses paging across several subviews

  • only shows one subview when not scrolling, and no more than two subviews when scrolling.

I can get a endless scrollview to work, but not with paging enabled. Paging will always limit my scrolling to the next subview.

So I'm thinking about creating my own UIView subclass which custom scrolling behaviour to mimic a UIPickerView. But before doing so, I wanted to get some opinions about the idea in general. Is creating a custom UIView the right way to go? Anyone has some experience with the expected performace? (There will be timers to handle the scrolling algorithm, which has to be recreated of course... :)

Another approach would be to subclass UIScrolView and implement the paging myself. I know when the scrollView starts decelerating , so maybe there is a way to overwrite the contentOffset to have it scroll into the right position...?!

Any help is appreciated! Thanks!


Here is a great custom component, which seems to be able to do everything you need:

http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/

It's not endless, but rather a modified UITableView with a huge number of cells.


Would it be feasible to just use a UIPickerView, but clipped to the middle row? You could turn off showsSelectionIndicator to remove the overlay and have the delegate pass back custom row views.

0

精彩评论

暂无评论...
验证码 换一张
取 消