I am novice in swift and I have found different tutorials with different solutions. My question is, if I create tab bar menu, I will get in storyboard three views: First Scene, Second Scene and Tab Bar Controller Scene. I understand that I need seperate swift files(classes) for First and Second scene. But in some tutorials people make also next swift file(class) for Tab Bar Controller Scene. Could someone tell me if I need it? If so, why? I have made my app without class for Tab Bar Controller Scene and everything works.
It is for controlling tabbar delegate or otheres and subview’s. I recommend you make a class file for tabbar too.
As you said it works without tabbar class file. But if you deal with complated source you will know that you will need the tabbar class file.
Related
I am working my way through the iOS Big Nerd Ranch book, and have hit a roadblock. This is about the extent of my iOS knowledge. I found a similar question from a few years back, but was not able to implement the solution so maybe my case is different: Programmatically assign view controller to tab bar controller
The Problem: The book has you delete a storyboard controller in order to implement it programmatically. Currently the app is two viewControllers and a Tab Bar Controller to navigate between the two. I deleted the viewController and implemented it in swift according to directions (pictured below), but I am not sure how to link this MapViewController back up with the Tab Bar Controller. Referencing storyboard objects programmatically has not been discussed yet, and I am having trouble piecing the steps together from other online resources.
What Happens When I Run It: My application opens up to the other viewController, which is a storyboard, and the Tab Bar Controller only contains a button for that one viewController.
The Question: What is the appropriate way (where should it be done, and how) to take the viewController I have defined in swift below, and place it in the Tab Bar Controller? Thank you very much for the help!
The storyboard with the MapViewController deleted:
The MapViewController that I want to put in the Tab Bar Controller:
As I understand it, one of the best ways of handling opening Views upon clicking a particular tableViewCell is by pushing to the ViewController.
However, this apparently only works if you only embed the ViewController in a NavigationController.
Would you then have to embed each individual ViewController in an Navigation Controller?
This sounds sort of repetitive and tedious - is this good practice?
This tutorial uses navigation controllers on all of the view controllers, but doesn't really say why
I just use one navigation controller, and it works fine for me. I've used one and had segues between multiple viewControllers including several tables as well as using buttons in some places, and still been able to navigate super easily. In main.storyboard, just select the first view that's going to be a part of it, then go to Editor>Embed In>Navigation Controller. Then, you just add in your segues (I believe they should all be Show(e.g. Push) segues to work correctly)
When running your app, there should be a bar at the top which can be used to go back (you can also edit the bar by adding other buttons or changing the color and title).
Here's some documentation from apple
I have an app which has 5 major user flows..each flow is a few screens linking to each other...so each flow warranties its own storyboard. Each storyboard starts with a custom view controller that is embedded in a navigation controller. So far so good.
Now all of this is "stitched" together via a UITabBarController. This is the most default UI design ever known to iOS.
But turns out I don't really know how to link from tabbarcontroller, which is in its own storyboard (that is set as the main one on code project) to any of the other storyboards.
This problem looks so! simple, so I think I am missing something utterly obvious, but I just can't figure out how to do it.
So how do I link from tab bar controller in storyboard 1 to the initial view controller in storyboard 2 when a tab is tapped?
You should do this in code. You can have the tab bar controller (tbc for short) and the controller in the first tab in the app's main storyboard, and in the app delegate, instantiate the other controllers using instantiateInitialViewController. Create a mutable array by copying the tbc's viewController array, add the other controllers you instantiated to it, and then set that array as the tbc's viewControllers array.
You have to add your viewcontroller programmatically in tabbar.
Well I wish there was some tutorial anywhere or any of the O'Reily Cookbooks would explain this but everyone only ever talks about using UITabBarController.
What I need in my app however is a custom view (basic UIViewController) with a NavigationBar (just for the title bar and a 'Done' button) and a TabBar in it.
The question is: How do I integrate the TabBar and connect views to each bar button (and add more bar buttons)? Can this only be done programmatically or is it possible in Storyboard? And which class needs to be the TabBarDelegate (I suppose my custom UIViewController)?
Does anyone know of a good guide for this or provide me with some hints?
Thanks.
UPDATE:
I decided to simply check in the TabBarDelegate for the tabBar.selectedItem.tag and instantiate a sub view accordingly from the storyboard and add it into a ContainerView that is sandwiched between my nav bar and the tab bar at the bottom. This works so far (although I'm not sure if there's not a better approach) but now I'm facing a different problem:
When a sub view is loaded into the ContainerView the whole tab bar disappears. Does somebody know why this happens?
It is very easy to crate Tab Bar Controller app with Storyboard. Apple even provides a snippet :) When creating a new project, just select iOS -> Application -> Tabbed Application.
Also, here is a pretty good tutorial: https://www.youtube.com/watch?v=RhsHtd6rAiQ.
Solved the original issue myself by creating a Xib with UIViewController in it and place a UITabBar and a UIView as container for subviews. Then load the xib with NSBundle.mainBundle().loadNibNamed() and create Xibs for the sub views that should be loaded and load these with loadNibNamed() and add them with viewContainer.addSubview().
I make my first "serious" iOS app, and have some troubles with the whole UINavigation concept, but all in order. I look answers for my questions but don't find what I want, so here it is.
I want to make menu to a game, it would be look like so:
1) It's a RootViewController and it contain some buttons: new game, options, about.
2) I think it will be another view controller (It must appear when we touch new game button, and we see a menu when we choose game difficulty) the buttons is: easy, medium, hard
3) The game view controller (I think that this VC won't be the part of UINavigationController).
I have some concepts that I want to embody in this menu.
Here is it: I don't want to use UINavigationController Navigation bar, I won't use standard slide animation for UINavCon, I want to make my buttons "move to transparency" and come back with another menu from paragraph 2 mentioned above, it's not necessarily to change background or something else except menu items.
I want to use custom back button, and want to add it to the position I want and not to Navigation Bar.
I have some ideas about animation of menu items.
I don't know this:
It is better to use UINavigationController for my purposes or it's better to use normal ViewController?
If I make a UINavigationController can I see it's "child VCs (I mean not a root VC)" in my storyboard or it will be programmatically created thing and I must make it UI in code? If i must do this programmatically, could I make a segue from UINavigationController from storyboard, or I must do this from code too?
Could I make a UIButton, for example, and assign it functions from a normal UINavigationController back button from Navigation Bar?
Some questions might be dumb, but hope you won't judge me hard.
Okay, I'll do my best:
For custom animations, see
Yes, you make a custom segue class with the animation. try: joris.kluivers.nl/blog/2013/01/15/… and developer.apple.com/library/ios/#featuredarticles/… and cmumobileapps.com/2011/11/04/a-short-tutorial-on-custom-segues
Yes, i think a view controller is your best bet. But by the way, even if you use a navigation controller, you still use normal view controllers. A UINavigationController holds different UIViews, which go forward and backward on the navigation stack. Also, you will need to look up what you need to do to hide the navigation controller.
You can see the child view controllers in a storyboard if you create them their, but not if they are created programmatically, unless you just have the view in their.
[self.navigationController popViewControllerAnimated:YES] will "press the back button" programmatically, so just link the custom back button to a method that calls this.
If that doesn't cover all of your questions, just comment and I'll answer any more :)