开发者

UIScrollView inifinite scroll without paging

first question here, be nice :P

I am trying to make an infinite UIScrollView (i used the "StreetScroller" apple demo project). When the UIScrollView is almost at the end of the contentSize, the contentOffset is set to the center of the contentSize and all the subviews are moved so it is transparent for the user.

It works correctly when you scroll slowly, but when you scroll too fast and that you reach the end of the UIScrollView, things become weird.

In my case i use a UIScrollView with frame.size.width = 320 and contentSize.x = 3 * frame.size.width. And this is what happen in the log开发者_高级运维s when you scroll too fast and that you reach the end of the contentSize (so if x > 560 when scrolling to the right) :

--> The UIScrollView is scrolling because of inertia

SetContentOffset called width x : 504.730072
SetContentOffset called width x : 516.878967
SetContentOffset called width x : 528.489990
SetContentOffset called width x : 540.347656
SetContentOffset called width x : 550.754028
SetContentOffset called width x : 561.200378

--> The UIScrollView reach the end of the contentSize so we recenter

The next call of setContentOffset is for recentering the view
SetContentOffset called width x : 320.000000

--> Here is the problem, UIScrollView does not take contentOffset.x changes in account, it continues the animation with the last contentOffset.x value used....

SetContentOffset called width x : 571.421753
The next call of setContentOffset is for recentering the view
SetContentOffset called width x : 320.000000
SetContentOffset called width x : 581.283447
The next call of setContentOffset is for recentering the view
SetContentOffset called width x : 320.000000
SetContentOffset called width x : 610.100952

And this continues until the animation finishes.

If somebody has a solution for setting the contentOffset and forcing UIScrollView to update its animation :)

I read almost all the topic on stackoverflow and other websites about infinite UIScrollView, and i did not see any working solution to change the contentOffset during the animation, and i tried to recenter in all the different UIScrollView delegate methods. And i don't want to change the contentSize during scrolling (it works only when you scroll at right or bot...)


I just noticed this issue in the Apple StreetScroller example running in iOS Simulator 4.3.

I saw this question here: Infinite UIScrollView gets strange behavior in iOS4.3 not iOS5 and just tested in the iOS 5 simulator and can confirm that it runs as expected there.

No idea what the issue is with that same code in 4.3.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜