How to make slide menu static or re-useable iOS? - ios

I am trying to make the slide menu re-useable without having to constantly add the same menu to every viewController in the menu drawer. How can I re-use, can I wrap all my view controllers within some type of main controller?

You could create a new root view controller which contains the slide menu and also contains a container view that covers the entire size of the screen.
Within the container view you would embed your old root view controller.
The slide menu is now available to every view controller in your application and you can make it appear or disappear when you want by animating its frame origin to slide onto and off of the screen.

You could use AMSlideOutNavigation
https://github.com/andreamazz/SlideOutNavigation

Related

Page View Controller :custom page slider

I am trying to implement a feature using PageViewController in iOS Swift language. In my scenario there will be images on all views associated with PageViewController. I will have buttons on top of images, (refer to example app's screenshot.) How can I implement that with change of page only the image slides not the buttons.
Finally I was able to do it, by following steps:
In your storyboard, create a standard Viewcontroller scene.
To this scene add your fixed buttons and a container view. Adding
the container view will automatically add an embedded view
controller. Select this and delete it.
Drag a Page view controller into the storyboard.
Select the container view and drag from the "viewDidLoad" item in
its "triggered segues" list to the page view controller. Select
"Embed" as the segue type.
Following delegate methods are to display dots of page controller, dots will appear at bottom of view.
presentationCountForPageViewController
presentationIndexForPageViewController
For your requirement need to create custom UIButtongroup or UIView group, so that you can place it anywhere in page.

Partial segue to show settings view

in the google maps app for ios. When you select the settings button, it will show you a view of options such as "traffic", "public transit", etc.
My question is how this is done on ios.
I tried following this tutorial but it says that it won't work on uinavigationviewcrollers. I have seen this partial segue of the the view in apps that use a navigational controller. How do they create that?
It's not a partial segue. It's not a segue at all, it use of containment view controllers.
Instead of a single view controller which transitions to a different view controller image one single master view controller. For simplicity, we'll say this view controller has two views (of the root), both of which cover the the whole screen. For this example let's think of them as "main" view and "menu" view.
Other than these two empty views, the view controller has no content. That's because this view controller does nothing other than manage other view controllers which get stuck into the two views. It will have a couple methods manage them, like presentInMainView:(UIViewController *)viewcontroller and presentInMenuView:(UIViewController *)viewcontroller
When the program starts running the master view controller will programmatically add the map to it's "main" view. The map view controller now cover the whole screen and looks and acts like it's the top level view controller, but it isn't. It's contained. At some point some taps the settings button and the map view controller will make a call to it's parent and say presentInMenuView:... and the master view controller will then load up a second view controller into the menu view. The menu view could even be located off the left side of the screen and the master view controller animates the menu view frame to side it right covering the whole screen. Assuming the menu view controller only has content which covers the left half of the screen you'll see the map view controller hiding behind it.
That really only scratches the surface, lots can be done with container view controllers. You could create a container which lets you brings up a dozen different views all populated with view different view controllers. You could size and arrange them on all over the screen and each child view controller could still only have to deal with it's own contents.
For more info there is the Apple Developer Guide and the WWDC 2011 Videos where it was introduced (session 102)
I used SWRevealViewController For similar type of sidebar animation.They given the good example of how to use SWRevealViewController also please try it once.

Designing view on top of multiple embed views

I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.

Keep a static graphic always fixed on screen while changing uiviews in xcode

Is there any way to have a static graphic on screen that doesn't move when pushing / popping view controllers?
The best way I can think to describe this is like a tab bar.
If you have a tab on a tab bar that has multiple pages that swipe left/right, you can view these different pages, and only the main content area moves, while the tab bar stays fixed and doesn't swipe in/out along with the content.
I want to do something similar with a custom toolbar I have created and added to a view, but just now it slides out with the previous viewcontroller and then slides in with the new view controller.
Is there any way to keep that fixed on the screen so that it doesn't move.
Hope that makes sense!
Yes, you can do this using container view.
It is fairly new to XCode, so it doesn't have the widespread use that navigation controllers and tab bars do, but it works similarly.
Basically, You will create a new UIViewController instance in storyboard, and put a Container View inside the view controller, filling the entire view controller. From there, you will right click on the view controller where your flow starts (probably either a tab bar controller or a navigation controller) select embed, and target the container view in your new view controller. Finally, you'll need to change the initial view controller (the arrow that points to the first view controller the app should load) to this new UIViewController that has your container view.
If you run your app at this point, you should notice no difference at all. The entire app is basically running inside the container view of that new view controller. Now, you can a UIImageView to that new view controller anywhere you want. Since the new view controller doesn't ever go away, the UIImageView you put inside it will stay there no matter what the container view is showing.
Hope this helps!
Note: I should add that if your program uses any modal transitions, that will cause the flow to exit the new view controller and it's container view as well, similar to how this affects tab bar controllers.

UIViewController as a subview for other view controllers

My app has a menu button which is available in every view controller. Every time a user taps on the menu button, a small menu pops up. The menu has multiple UIButtons, and each button links to another view controller.
My current solution is to create a view controller with a nib for the menu view and add it as a subview to each of the other main view controllers.
Is there is a better solution?
There could be multiple ways of doing it and I don't think there is the best answer.
However, in the performance perspective, implementing a view container such as UINavigationController or UITabBarController would be most effective.
Implement a root view controller (whose view is added as the only direct subview of the application window), and add the menu as a subview of its view. Let the root view controller decide (or know) which view to display, and add the view as a subview of its view, below the menu.
In this way, the view for the menu need not be removed and added again to the current view hierarchy.

Resources