通过滑动改变视图
我是 Cocoa/Objective-C 的新手,所以我希望你能帮助我解决这个问题:
我在两个不同的 xib 中有两个视图控制器,我想用手指在屏幕上滑动来在它们之间切换。
任何人都可以给我建议吗:)
i am a newbie in Cocoa/Objective-C so I hope you can help me with this question:
I have two View Controllers in two different xib's and i want to switch between these with a swipe of a finger on the screen.
Can anyone give me an advise please:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据通过滑动在视图之间切换所要实现的目标,有几种方法可以实现。
以下是一些我想到的:
UIScrollView,这些视图作为子视图。您可以将滚动视图设置为分页模式,它会为您处理所有滑动操作。
使用
UIGestureRecognizer
,特别是UISwipeGestureRecognizer。将其添加到两个视图中并创建一个“主”类,该类决定用户执行此类手势时会发生什么。Depending on what you to achieve with switching between the views with a swipe, there are a few ways to do it.
Here are a few that come to mind:
UIScrollView with those views as subviews. You can set the Scroll View to paging mode and it handles all swiping for you.
Using
UIGestureRecognizer
s, particularly the UISwipeGestureRecognizer. Add it to both views and create a "master" class that decides what happens when such gesture is performed by the user.