How to implement swipe views with CollectionView/TableView Controllers? - ios

I am creating an app using Swift, and I'm still trying to figure out what the best configuration would be.
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.
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
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.

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

You can use a scrollview as a container, put three ViewController in it.

Related

How to create sideway swipe with the View coming sideways? With Swift using Xcode

I am trying to create an iPhone app where you swipe right or left to get from one view to another. I know how to do it from scratch with my own code, but I want to learn the Apple way of doing it, which means drag and drop the UISwipeGestureRecognizer icon into the storyboard and change settings in some way. I can get it to have a sideway swipe, but not with the views appearing from the sides. Only have the view appear from the default bottom.
So frustrating not coding from scratch, don't know where the problem is. Help very much appreciated!
I don't think you are clear on whether you are trying to have "views" appear from the sides or "view controllers" appear from the sides. There is a distinction. What you wish to do in general is drag a swipe gesture recognizer and drop it onto the view you wish to recognize the gesture (for example the top level view of the scene). Then you need to control drag the gesture from the top of the scene to the code and create an action method. Within that action method, you can perform a segue to another view controller, if you wish to transition to an entirely new scene. Otherwise, you can initialize another view and animate it onto the screen.

what do I need to use to change controller when sliding left?

I want to create a touch control, where I slide left and the view scrolls in a paged mode (like in Photos app where you slide between photos) but instead of a view in a current controller coming in, I want a new controller to come in with it's own view. What control should I use to build something like that?
You can use UIPageViewController to navigate between different ViewController like a scrollView
You can follow this tutorial
1-http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/
2-http://www.appcoda.com/uipageviewcontroller-tutorial-intro/
3-http://www.makemegeek.com/uipageviewcontroller-example-ios/
hope it will help you

Creating an animated slide-down menu using Autolayout

I'm trying to upgrade my app to use Autolayout, basically to be future-proof, but I'm running into a huge amount of problems TRYING to use autolayout.
What I have is a view controller which contains two UINavigationControllers (using view controller containment). If I press a button, I want the menu to come down. Within the menu, i'll push view controllers and whatever else, and if the user wants to quickly get out of the menu they can tap the bottom part of the view at the bottom. Basically, if you've used Uber, something similar to that.
I have fiddled and fiddled but I can't get it to work correctly. The best I got was set up a XIB for the container view, and have two views within it (as well as a few outlets for some constraints). Within code, I change the constants of these constraints to make the menu view move and to force the correct height of the menu (which is the same as the bottom minus an offset).
The problem comes in when I try to push another view controller in the menu as it seems to throw away the height constraint set on the menu -- new view controllers take up the entire screen. I don't want to use clipSubviews because that doesn't really solve the problem, and sometimes I use overlays which need to go outside of the view.
To be honest, I don't even really care that much if this animation even uses autolayout, but I want to be able to use it on the view controllers within each navigation controller. Right now, if I turn it on, the animation won't work at all.
Any ideas?

Pull out side menu in iOS examples

I have seen reveal menus like the one in Facebook app. But that is not I want. I would like to have an arrow and when u click the button the slide menu should slide out from hidden.
Is there any code examples or opensource libraries that is able to do this?
Need some guidance on this. Thanks..
For example, i have a button with an image called pull me and it is sitting at the bottom and when i pull it, the menu comes out on top of existing view..
To achieve this functionality, you'll need to create a custom container controller class and instantiate it with child view controllers. The views of the child view controllers will be managed by the container controller using custom animations.
It would be better if you build your own container controller, but if you really need a library, here's one : http://www.cocoacontrols.com/controls/slide-navigation-view-controller
It manages sliding the primary/root view in any one of the 4 directions (up, left, down, right).
Hope this helps

Can I Have Multiple Hidden Views In A ViewController?

I know, this seems a bad solution, but I can't think or figured out how to make something better.
What I need to do is like a menu, iPad menu, with a toolbar up and bottom, and an image in the background. In the bottom toolbar, I'm going to have 4 different buttons. Every button is going to create the options menu in the middle of the screen. One button needs to display 3 options (buttons with images), another 4 options, another 8 options (for this, I'm going to use Scroll View and Page Control, because I'm going to need 2 pages), another 2 options.
I was trying to use subviews, one subview for every button, and I was added the options in the subviews. When I select one button, its subview was loaded, but when I tried to change its position and size, its buttons was missed, the subview was empty...
Now I'm going to have the 4 subviews in the ViewController, but hidden. When I select one button, the view is going to appear, and the others views are going to have hidden. This means, that all the subviews are going to have loaded. Is this convenient?
Is this method requires a lot of memory?
If somebody have another and better solution, I'll be completely grateful...
Thanks
Yes, you can have multiple hidden subviews within a view controller, but I don't think it's the most practical way of going about it.
You mention that the menus are to appear in the center of the screen. In this case, I think a better approach would be to create a separate view controller for each of your menus and then have your main view controller present them modally by using the view controller's modalPresentationStyle property. By doing this, you're saving yourself a ton of time by not having to write code that checks for which views are hidden and which aren't; you're letting the API do its job, so at most you'll need to implement a few methods such as dismissModalViewControllerAnimated:.
Check out Apple's documentation about UIViewController, and more specifically the section called "Presenting Another View Controller's Content".

Resources