UzysSlideMenu: how to use several view controllers? - ios

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

Related

iOS/Swift/Storyboard: Add PageViewController using only *part* of screen?

New to Swift. I've seen many tutorials on using PageViewController, but they always have the Page View taking up the whole screen.
I'm trying to implement a Page View functionality in only PART of my app, not the entire screen, so that other "static" elements (e.g. a ToolBar) can remain. Something that would look kinda like this...
https://imgur.com/9wM1vll --- (Need more rep. before embedding images)
...where swiping will cause different images to appear as seen in various PageViewController tutorials (e.g. http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/).
When I start with a Single View Application, I go to Storyboard and try to drag a "Page View Controller" from the Object Library into the ViewController frame, it just "bounces back", i.e. it won't let me add the Page View Controller.
Now, if I add the Page View Controller to the white space around the other View Controller, then this gets back to the tutorials where the PageViewController takes up the entire screen and I don't want that.
How does one achieve this?
Thanks.
Sorry if this is a dupe but I have tried & failed to find anything that answers my question directly. The closest are Implement PageViewController in TableViewController details or Adding a UIPageViewController to a subview, subview only shows edge of pageContentview, but these are not similar enough for me to comprehend, plus they're in Objective C which I've not yet learned.
When I start with a Single View Application, I go to Storyboard and try to drag a "Page View Controller" from the Object Library into the ViewController frame, it just "bounces back", i.e. it won't let me add the Page View Controller.
A page view controller is a view controller. Thus, to make its view occupy only part of the screen, you must obey the rules for view controllers in general: you need a custom parent view controller, and the page view controller must be its child view controller — and you must do the elaborate dance that this entails when you create the child and put its view into the interface.
To get the storyboard to do the dance for you, use a Container View and hook it by its embed segue to the page view controller:
(Still, in my opinion it is always better to learn to do the dance manually, in code, yourself.)

Best practice to develop common header view across all controllers/windows in iOS app

I'm keeping on developing an iPhone app (rigth now native one) and I would need to use a common "header" for all views but I don't want/need a UINavigationBar and prefer much more have a common "partial view". It will have some actions to perform but always the same ones (showing notifications panel, basically). It should be something like you can see in the screenshots.
I don't need (I feel) delegation because the controller's view can handle notifications and show them when user clicked the customize button.
I don't mind to use a Nib o make the view hardcoded but I'm not sure how I must make an instance of the view or the controller that handles it within each app tab (I'm using UITabBar as navigation control).
From my point of view it doesn't exist a way to get a common controller to call wherever needed; you just can use some method to present new controller as modal o push it out and I think that is not what I'm looking for.
Any idea is welcome. Thanks
Create a custom view controller with 2 subviews. Subview 1 is the header. Subview 2 is the container view where child view controllers are displayed (your tab bar controller in this case).
Your custom view controller could be the delegate of the tab bar controller if you want, so it can be notified when the tabs change and update anything on the header view.
Well, finally is have used the solution I found on the link http://patientprogrammer.wordpress.com/2012/03/12/re-usable-subviews-in-ios/
I have created a Nib with a view controller and then, in the main window I have added two view, the top one subclasses the view controller for the Nib view and it is rendered automatically when app is launched without a single line of code within "main" controller. See the screenshots for more detail:
Thank you very much for your help

How make static view on any viewcontroller in Xcode?

I Have interesting question.
I have two screens, I need that would be the third screen elements (buttons, label) are static and do not change when you move from one screen to another. .
So MAIN DISPLAY 1 will be change, DISPLAY 2 too , but button and others(label for example) need be static.
Big Thanks for all help, sorry i don't have any code with this problem. Because i don't know how this make...
Ok, so if you have a UI that won't change it's content you have to consider the following:
If the user can navigate from one screen to another, then you will have to create multiple view controllers(it can be done in other ways but this is the easiest and best way to doit) that will have their own UI, that can be easily created in storyboards like this:
Create a new project that use storyboars (you can use the Xcode templates that support your needs)
In your generated storyboard, drag and drop a new UINavigationController, and in the Attributes inspector check the Is initial view controller
Drag another UIViewController into your storyboard, select your navigation controller, hold right click and drag to the newly added view controller, a popup will appear and from that popup select root view controller. Now the newly added view controller will be the first view that the app will display. On this view controller add your UI elements (buttons, labels, etc). If you want another screen to be shown when a user taps on a button, drag another view controller and select the button from which you want to display the next screen, hold right click drag to the newly added view controller, from the popup select push. Now when the user tap on the button the next view controller will be shown and as a bonus because you use iOS, the system will create a back button so that you can go back to your first view controller.
Ok, this is the a basic tutorial from which you can start and expand, but for that you will have to read more, spend nights on google/SO to find solutions, you will learn apple docs by heart and other things that are required so that you can be a great iOS developer.
My the iOS force be with you and Steve Jobs watch your steps.
This is off the top of my head:
you could put a view into your uiwindow and place your static elements there, and then give a transparent background to display1 and display2. then you can have the two displays forward their touches to the background elements to have actions on the buttons. im sorry i dont have any code, but i never tried that ;)
A much better way is to instantiate your ViewController like so:
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
Then inside your instantiated View Controller you setup a static variable that holds that instance of the View Controller:
public static StaticViewController staticViewController;
When the Static View Controller fires up for the first time:
staticViewController = this;
Now in the future when you fire up the Static View Controller (from wherever in your app) you can check to see if the StaticViewController.staticViewController variable is null or not.
Use simple if else logic to load it up accordingly:
if (StaticViewController.staticViewController == null) {
StaticViewController.staticViewController staticViewController = this.Storyboard.InstantiateViewController ("StaticViewController") as StaticViewController;
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
} else {
if(!StaticViewController.staticViewController.IsBeingPresented) //safeguard against click happy users
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
}
You should add the static views to your UINavigationController or whatever controller you are using for managing multiple controllers.

A Tabbed application with a different Master Detail Table View on each tab, using Core Data

I was hoping someone could help a noobie out.
I am trying to create an iPhone/iPad app that uses tabs as its main navigation. The first tab will be kind of a home screen with basic info and a feedback button etc. The other tabs (3-4 tabs) each need to display a different "section" of the app. Each section will display a table view and navigation controller (using Core Data). These table views are unrelated to each other, each using different tables from the database (sqlite).
To illustrate this lets say tab 1 is the apps Home, tab 2 lists your grocery list, tab 3 lists recipes and tab 4 lists coupons available. They all fit together in the app but they come from completely different tables. Each navigation controller that appears on each tab is Completely different. Im using it like secondary navigation within the tab.
So my question is, does anyone have any tutorials that illustrates this technique? And if not do I have to create a different fetchedResultsController for each tab? I started the project using the Tabbed application template, I then created another dummy project using the master detail template and added the master detail code and xibs to my tabbed project. So I now have tabs that display the generic time stamp entity that comes with the master detail template however I cannot seem to get the tabs to display different data.
Also how can I create a navigation controller for each table view / tab? All of the documentation says to initialize it inside of the AppDelegate however if I put it there how can I get a different controller for each tab? Do I declare 3-4 controllers in the app delegate and some how assign them to each table view? I have not seen an example of this anywhere even though it makes sense. Tutorials would be much appreciated.
Thank you so much in advance. Im just stuck here. :(
So to start off each tab (I assume you're talking about a UITabBarController) will have it's own UINavigationController->UIViewController. I don't know of any tutorials about using the master-detail inside a tab and I haven't done it personally, but for your second question about navigation controllers inside your tab you would do the following:
Start off using a tab template using storyboard.
Inside your storyboard you can see that they have the two view controllers and they are tied in and stuff. I would just delete them as they aren't needed.
From the right side you'll drag in however many UINavigation controllers (the gold ones) you need. When you drag it in it should bring in two views, the controller and the root view.
From the tab bar controller control+drag to the navigation controller and connect it to Relation-view controllers. Do this for all the navigation controllers
Your storyboard should look somewhat like this:
You now have all view structure set up. So you'll now need to create all the classes for those. As you mentioned you'll create a recipe view controller, shopping list view controller...
Set the blank views to use the classes you just created created. From each of these classes you can push views to their navigation controller and it will push it onto that stack and if you switch tabs you'll start where that one left off.
Inside of each of these Classes there will need to be a NSfetchedResultsController that will tie into acore data database (Housed in the delegate or another class) and control that table.
Here is a great tutorial I've used for setting up my first nsfetchedresultscontroller. It goes through the entire process from start to finish.
http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller
I hope that gets you off your stuck phase. let me know if there is anything unclear on the set up.

How to make viewViewAppear getting called in both Master and Detail view whenever they appear

My app has 5 screens which are controlled by a tabbar at bottom, and one of them is a SplitView.
My Problem is:
The master view is just cause viewWillAppear only one time at first rotation.
The detail view is also just cause viewWillAppear only one time at first load.
While I would like viewViewAppear of both master and detail view are getting called each time this screen is opened, because there are 5 different screens, and user may leave this screen to view another, so I would like to know whenever master and details view appear to change layout or refresh data.
Please help me, thanks in advance!
It looks like you just anwsered your own question. I know its something you dont want to hear but apple's documentation says it must get the root view. Try to restructure your app a bit.
Link to documentation:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html#//apple_ref/doc/uid/TP40007457-CH6-SW2
From the documentation:
A split view controller must always be
the root of any interface you create.
In other words, you must always
install the view from
aUISplitViewController object as the
root view of your application’s
window. The panes of your split-view
interface may then contain navigation
controllers, tab bar controllers, or
any other type of view controller you
need to implement your interface.

Resources