Xamarin.SideBar on different pages with navigation controller - ios

So i'm using this(Xamarin.SideBar) component in my project.
The biggest problem that i need to have SideMenu on all my main pages(that are represented as tabs,each one have an navigation controller,see pics).
So my pages looks like on the screen:
where A,B,C,D,E,G are tabbed pages,which contains a navigation controller.(green circle means that were located now at page A)
And now i'm opening my SideBar
Menu are opened and the first button clicked,bam and we're on another ViewController that holds Navigation stack with button Back to ViewController(page) that called A(same for other pages from tab).
My storyboards looks like:
And i'm so confused how to achieve my goal !?
Seems that i need to make an BaseController that will create ONEs this MenuController of SideBar , but architecture of Xamarin.SideBar component scares me,because i need to put everytime a NavController and ContentArea...
Any advice? Thanks!

First of all, do not use the Xamarin Component, instead use the nuget package that is more updated. Here the link. Don't worry it's the same library, it seems they will not update the Component, but who needs a Component when you have a nuget!
Regarding your question, yeah you are correct, you will need to create a BaseViewController that will be holding the side menu. Your main controllers (A,B,C,D,E,F,G) will all be deriving from this it so you don't have to be repeating code.

Related

How do I add code to my viewcontroller.swift for views connected via a navigation controller?

So I am pretty new to Xcode (but not programming in general, have learned a bit of python and java) and I am trying to figure out, for the life of me, how I connect bits of code in other views besides the first one when they are linked from a navigation controller.
To paint a picture of this, I essentially start out with a single view application, I have the first view and I add a button to it and then I embed it in a navigation controller by doing.. Editor -> Embed In -> Navigation Controller. The next time, as I have been following from various guides online, is that I control drag that button to that view and hit "show" to link them. Now say I have another button in that new view I just linked to. Xcode doesn't seem to let me just control drag that button onto the text in viewcontroller.swift, I believe that this is because they are two separate view controllers now however I have not a clue where the second viewcontroller2.swift file may be. Or, maybe, there is an easier way to link the two views together and actually be able to modify the source files?
If you're trying to find a "ViewController2" you won't find it, because you have to create it! Use Command-N to create a new file and choose "Cocoa Touch Class". Name it something like SecondViewController and make sure it's a subclass of UIViewController. Now you can go back to interface builder and change the class of the second view controller to whatever name you just chose, like SecondViewController.
To address the other part of your question (I think), I'm not exactly sure what you're trying to do. If you want some of your data to transfer to the new ViewController, use the prepareForSegue function in the first ViewController.

UzysSlideMenu: how to use several view controllers?

I just came across a slide-in menu I really like: https://github.com/uzysjung/UzysSlideMenu
I would like to use this menu for an application that uses several view controllers (UIViewControllers and UINavigationControllers).
In Xcode, I created a single view application and made the view controller (MenuViewController) show the menu, like the creator did in his example project. I added more view controllers to the storyboard and connected them via segues to the MenuViewController. Upon selecting a menu item, these segues are triggered and the selected view is shown - so far so good.
But now, I run into the following problem:
All my view controllers are shown in full screen. That means that VCs that get segue'd in the viewport don't show the menu, because it's just not implemented there. I could put the menu in every VC, but that doesn't seem to be the right way to do it (even if I use some custom delegate method that every controller calls, like putMenuInViewController:(UIViewController *)target). I think I need something like a global singleton for the menu and make it appear in every view controller, but I have absolutely no idea on how to it or what to google for.
Any points into the right direction are greatly appreciated :)
I think you need to implement one root view controller with this menu as singleton, and add other view controller as child view controller to it.
I wrote a post about it, you can find it here:http://antrix1989.blogspot.com/2013/09/uiviewcontroller-as-singleton.html

Two UITabBarControllers sharing one ViewController (as tab content)?

Situation: two UITabBarController's, each with their own tabs, but last tab in both is identical so want one UIViewController to show content.
Issue at runtime: Shared item only appears in one of the tab sets when shown.
Question: anyone know a way to make this work?
Link to external graphic of storyboard setup: (sorry, don't have enough reputation to post images here!)
Storyboard graphic
An Xcode project with that storyboard:
XCode Project
Each tab content item has it's own UIViewController class. They contain no code except the line to make the back buttons work.
(Yes, I know this is odd. Real situation is an iPad app where tab controllers are shown in popovers; popovers are "property editors" where different objects have different properties, but all share a common set of properties... thus one tab for "unique" props, one shared tab content for the "common" props all objects have.)
I've found a couple ways around this to get the effect I want, but if this storyboard worked it would be a much easier solution.
-- Other info, somewhat unrelated to question --
Alternate solution I'm using: TabBarControllers only link to one VC as tab content. When that tab VC loads, I use code to (a) instantiate shared VC from storyboard by identifier, (b) add that new VC object to the TabBarController via [tabController setViewControllers:list animated:NO].
(Another possible solution I like even less: not using a TabBarController, and presenting content VC's with my own "tab" graphic drawn into them, each showing "myself" as selected. Yuk.)
So I have a working solution, I'm just curious as to why this doesn't work (just a known thing in iOS API, or some magical property setting that might render it functional?)
You can't put the same view controller instance into two tab controllers. The problem is that a view (UIView) instance can only have one parent view (superview). When you try to add the view controller to the 2nd tab, the view controller's view gets removed from its first parent (the first tab) and then added to the 2nd tab.
I stumbled upon your thread while running into the same issue today...
The solution is to just make a duplicate of the view controller in story board and attach the duplicate to the other tab bar controller.
I just did it and it works...
I think the 'rdelmar' is right about this... copy it and set it ..!!
I ran across this same issue today. I managed to come up with a workaround that seems to do the trick. The key is to add a layer of separation between the tabbar and the controller you want to reuse. From each tabbar, I created a relationship to a distinct UIViewController with a container view. Then you can do an 'embed' segue from the container to the controller you actually want to reuse as the tab view. It is not quite as clean as a direct connection (not sure why that is not supported) since you do have to create a controller class for each reuse case. It is still a better solution than the nightmare of having to duplicate the actual tab view ( as well as any additional views that connect to it) for every use.
Hope this helps. Let me know if anyone needs more details.

IOS slide menu like facebook and path 2.0 that works with storyboard

I try looking everywhere for opensource but couldn't find a cocoa control that has the following combination.
Slide Menu
Story Board.
Navigation controller.
TabBar controller.
I found one open source control that works with 1,2,3 but doesn't work with uitabbarcontroller.
http://www.cocoacontrols.com/platforms/ios/controls/saslidemenu
I used IIViewDeckController in a project that involved all of the things that you list.
I made a video (3 parts) on youtube on how to make a sliding menu like the on you are looking for. I show you how to set up the project and get everything linked up.
http://www.youtube.com/watch?v=tJJMyzdB9uI
The way this is set up, you should be able to just select UINavigationController instead of UIViewController when creating your files from the first video.
I use ECSlidingViewController because its the easiest to customize.
Hope this helps!
Here is a simple one I wrote. It's built on top of UINavigationController so you can use all UINavigationcontroller functions as well as slide function. No need to inherit any base class for your ViewControllers like other libraries require. Works both on Storyboard and in code.
I haven't tried, but I'm pretty sure if you set a tab-bar-controller as the root view controller of this custom navigation controller it should work as expected.
https://github.com/aryaxt/iOS-Slide-Menu
https://github.com/arturdev/AMSlideMenu
You can use this simple library.
Just connect your menu (tableViewController) to your tabBarController with a custom segue of type AMSlideMenuContentSegue.

Best way to combine UI Navigation Controller with UITabBar Controller?

I'm at a point in the development of the app I'm working on where in order to complete the assignments given to me, it seems like the best way to accomplish what I need is to combine a UINavigationController with a UITabBarController.
Structurally, the app has a home page, and the rest of the app is navigated through the UITabBarController. This is a sound design for the original, but when I took over the development process of this, I had to make a lot of additions to the app, and there's technically supposed to be a "second" section which adds extra "features" if you will that aren't necessarily related to the main functionality of the app itself.
Basically, since everything begins at the Overview, the user is supposed to have a choice between just diving into the app itself, or using some of these extra features. I'm thinking the Navigation Controller would be fitting for the extra features, but I'm not sure how I can add to it.
What I need to know is - is this solution to the problem sound? If so, what's a good way to accomplish this? Is it ok to have a separate UIWindow class to link the Navigation Controller up with the TabBar Controller?
Granted, this app has used a lot of nib files, and every time I've tried to do something programmatically, it just hasn't worked. Thus, if someone could point out a NIB method of achieving this, I'd appreciate it.
According to Apple recommendation, UITabBarController should always be the root view controller of your app. So basically your main view is just one tab of your tab view controller, and so you just need to embed your main view controller in a navigation controller. This way you can navigate to whatever page you wish within that tab using the navigation controller, or you can go to other tabs using the tabbar controller.

Resources