Autoscrolling in a UIScrollview

2019-03-03 13:36发布

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. :)

3条回答
趁早两清
2楼-- · 2019-03-03 14:16

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.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-03 14:22

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

查看更多
成全新的幸福
4楼-- · 2019-03-03 14:38

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..

查看更多
登录 后发表回答