简体   繁体   English

如何使用CollectionView / TableView控制器实现滑动视图?

[英]How to implement swipe views with CollectionView/TableView Controllers?

I am creating an app using Swift, and I'm still trying to figure out what the best configuration would be. 我正在使用Swift创建一个应用程序, 我仍然在试图弄清楚最佳配置是什么。 What I'd like to have is 3 screens (the left screen would have a side out panel) that users can access via the navigation bar menu or just by swiping left/right the screen for more accessibility. 我想要的是3个屏幕 (左侧屏幕将有一个侧面面板) ,用户可以通过导航栏菜单访问,或者只需向左/向右滑动屏幕即可获得更多可访问性。

I could easily create my TableViewControllers/CollectionViewController and the menu, but I'm struggling at making the screen able to detect users gestures at the same time, and I'm not sure whether I should use 3 View Controllers and then add the Collection View/Table View via the Storyboard, or directly use the CollectionViewController/TableViewController 我可以轻松地创建我的TableViewControllers / CollectionViewController和菜单,但我正在努力使屏幕能够同时检测用户手势,我不确定是否应该使用3个视图控制器然后添加集合视图/ Table View通过Storyboard,或直接使用CollectionViewController / TableViewController

I added a picture here describing what I'd like to accomplish: 我在这里添加了一张图片,描述了我想要完成的事情:

我想要完成的草案

Also, I wonder whether I should use storyboards or not for my project. 另外,我想知道我是否应该使用故事板来实现我的项目。

I know that's a lot of questions ! 我知道这是很多问题!

Any ideas please ? 有什么想法吗?

Thank you very much and have a good day, 非常感谢你,祝你有个美好的一天,

J. J.

您可以使用scrollview作为容器,在其中放入三个ViewController。

You need to add 2 "swipe gesture recogniser"s to your middle screen(your second screen in your attached image) , and set one for identifying left swipe and another for right swipe. 您需要在中间屏幕(附加图像中的第二个屏幕)中添加2个“滑动手势识别器”,并设置一个用于识别左侧滑动,另一个用于右侧滑动。 Create action methods for both in your view controller and add code accessing left screen and right screen in respective methods. 在视图控制器中为两者创建操作方法,并在相应的方法中添加访问左屏幕和右屏幕的代码。

note - you need to drag "swipe gesture recogniser" to top bar of your view controller scene to add it. 注意 - 您需要将“滑动手势识别器”拖动到视图控制器场景的顶部栏以添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM