Autoscrolling in a UIScrollview

前端 未结 3 803
借酒劲吻你
借酒劲吻你 2021-01-27 19:42

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 t

相关标签:
3条回答
  • 2021-01-27 20:19

    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.

    0 讨论(0)
  • 2021-01-27 20:23

    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

    0 讨论(0)
  • 2021-01-27 20:24

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

    0 讨论(0)
提交回复
热议问题