Autoscrolling in a UIScrollview

◇◆丶佛笑我妖孽 提交于 2019-12-04 06:26:16

问题


I have been only using Xcode 5 for a little while now and I need help when it comes to auto scrolling a UIScrollView. I am using a single view application. I need the screen to scroll down at a pace that speeds up incrementally. Also I need the screen to keep progressing even when the screen is touched. If someone can explain which code goes where it would be great! Your help will be greatly appreciated. :)


回答1:


OK, just adding this from your duplicate question.

I suspect the Piano Tiles game is actually using something like Sprite Kit.

This allows a lot more control over thing like "scrolling" speed.

Instead of using a UIScrollView you would use an SKNode as a layer with the buttons added to that parent layer.

Then using the update game loop you can incrementally increase the speed of the movement based on the time since the game started.

In essence... don't use UIScrollView, don't use UIKit, use SpriteKit.




回答2:


Check out this library: https://github.com/danielamitay/DAAutoScroll

It stops to scroll when the user touches the screen and that's the only solution I see possible. I don't even see why you wouldn't want the user to be able to stop the scrolling..




回答3:


I can see a few options:

1) suggested by Fogmeister, use Sprite Kit instead.

2) see setContentOffset

3) just use a normal view as parent, then have another child view on top with the full content (would be longer than the parent view), create a NSTimer to periodically call a method which scrolls the child view in whatever direction and speed as required. Note that might need something on top to mask around the child view from showing the suppose-to-be-hidden sections of the child view.

Hope this helps



来源:https://stackoverflow.com/questions/24491410/autoscrolling-in-a-uiscrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!