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().
Related
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.
I am new to iOS development and have a question about what component I should be using for a particular UI aspect. The app I am working on has need for a toolbar to go across the bottom and at times to be visible across all screens. This toolbar is going to be used to manage the playing/pausing of some audio files which will play as the user navigates between screens within the app. My question is should I be using a Toolbar, a Navigation Bar or something else to achieve this?
To create such a toolbar you can use whichever component you want. There is no built-in solution on iOS for such a scenario and there is anything in the human interface guidelines that may help you to make this decision.
From my perspective, the problem here is how to make this toolbar visible on all your screens. This depends on your view controllers hierarchy which I know anything about.
Navigation controller
If you use UInavigationController to organize your screens you can use it's built-in toolbar to achieve your goal. The drawback is that the UIToolbar of UINavigationController is per item view controller so you will need to configure it each time a new UIViewController is pushed on the stack.
Containment
The general solution is using the containment API. You can create let's say root view controller of your application which will contain your toolbar and will host other view controllers of your application. For the presentation purpose, I configured it on a storyboard using a container view. You can see it on the image below.
Modal presentations
Neither of above solutions will work when you decide to display a view controller modally. In this case, you will need to make additional effort to put the toolbar in such a view controller.
Other options
You probably won't be able to achieve that using UITabBarController unless you are very stubborn. But if you are new to iOS I don't recommend trying. The same is for UIPageViewController. I'm not sure about UISplitViewController because I have a very little experience with it.
It will become clear as you read that I have very little experience programming please excuse me for an elementary question. I have on the storyboard the template for a tab based app. which has two view controllers both of which have a web view on them and both seem to be working fine. As I needed a third tab I dragged a view controller onto the storyboard and linked it to the tab bar controller, I also created a "thirdViewContoller.swift" file which was copied from one of the other two which was in the template. Ran the app and everything works fine. I now drag a UiWebView onto the third view controller and unlike the other two when I try to control drag the webView to the code it will not link up. What am I missing. Many thanks for any help.
Did you check that your thirdViewController class is set in the storyboard? Click the yellow circle on your third view controller that you added in the storyboard. Go to the Identity inspector tab. Make sure the "Custom class:" field is set to thirdViewController. Now you should be able to make an IBOutlet for your web view by control dragging.
I want to know if its possible to create a view that will stay above all the other viewControllers that i push in my navigation controller.
I'm using storyboards in Xcode 5.0.2 with iOS6 plus platforms.
just like the UITabBarController works by nesting the navigation controller inside it so the tab bar stays at top no matter how many view controllers are pushed inside it. i want to create the same functionality but i can't use the tab bar controller due to the fact that its not very customizable and it doesn't look well for my app in iOS versions below iOS6. so my only option is to create my own view that will stay above a uinavigation controller.
I'm not sure if this is possible so kindly let me know if anyone knows a way to do this or anything similar. Any help will be greatly appreciated. thanks.
I am completely new to ios development and I am only interested in developing for ios5.
I have an app with some scenes, they are mostly tableviews. I also use a navigation controller
I however need to add some status text and buttons that are always visible in all scenes and thought that a toolbar added to the navigation controller should do the trick.
so i thought that i should only have to drag out a toolbar in storyboard to the navigation controller, but it does not stick there. I can add it to the bar underneath with first responder and navigation controller but that does not help me (small icons).
I can also not add it to my table view (but if i drag out a plain view I can add it there)
do I have to make my own custom navigation class that the navigate view uses and then programatically add my toolbar?
Had the same question recently. Check Attributes Inspector in your ViewController's properties in storyboard. There you can define a Bottom Bar.
Well, inside the UINavigationController, you should have something... A UIViewController for instance. You can easily add a UIToolBar by dragging the object inside the UIView of the UIViewController. What might being happening is that as the root view you have the UITableView, in that case I think you can't do that. But to better understand, just take a small print screen of your StoryBoard.
If you zoom up to 100% on the storyboard it should drag.