After finally getting my UITabBarConntroller to work, I have read in the apple docs, that I should not use a UITabBarController as a child of my Navigation Controller.
My app, segues from a TVC to my TabBar, which has a few tabs.
For example
I want to modal segue from each coloured view.
I am wondering if the red view should be the delegate for each of the views, or should they all be independent.
What you are trying to do here is basically to implement your own Tabbarcontroller. Apple does not recommend to put a Tabbarcontroller as a child of a Navigationcontroller due to usability reasons. Technically, you can do this but it is not really good as users of iOS are used to have a TabbarController as the root view of each navigation stack and therefore an approach like yours might make your app confusing and hard to understand.
Nevertheless, if you insist to stick to your idea, you can just simply put a tab bar controller into a navigation controller in your storyboard which should do its work. Still, I would recommend to rethink your app's navigation structure. Take a look at other popular Apple apps and Apple's Tabbar Controller Documentation as inspiration.
Related
I have a stack like below hierarchy (I'm using programatic way, so I done it)
UINavigationController -> UITabbarController -> UInavigationController -> UIViewController
-> UInavigationController -> UIViewController
As Apple Docs say for pushViewController:
The view controller to push onto the stack. This object cannot be a tab bar controller
I need to know If this has a known bug or will CERTAINLY causes a bug.
I really searched a lot for similar posts but none of them give me an acceptable answer.
Using UITabBarController with UINavigationController - Swift 3
Can you push a UITabBarController inside an UINavigationController
From Apple:
Before creating a tab bar interface, you need to decide how you intend
to use a tab bar interface. Because it imposes an overarching
organization on your data,you should use one only in these specific
ways:
Install it directly as a window’s root view controller.
Install it as
one of the two view controllers in a split view interface. (iPad only)
Present it modally from another view controller.
Display it from a
popover. (iPad only)
Installing a tab bar interface in your app’s main
window is by far the most common way to use it.
In such a scenario,
the tab bar interface provides the fundamental organizing principle
for your app’s data, with each tab leading the user to a distinct part
of the app. You can use tab bar controllers by themselves or in
conjunction with other view controllers to create even more
sophisticated interfaces. For more information, see Combined View
Controller Interfaces.
It is also possible to present a tab bar controller modally if a very
specific need makes doing so worthwhile. For example, you could
present a tab bar controller modally in order to edit some complex
data set that had several distinct sets of options. Because a modal
view fills all or most of the screen (depending on the device), the
presence of the tab bar would simply reflect the choices available for
viewing or editing the modally presented data. Avoid using a tab bar
in this way if a simpler design approach is available.
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.
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'm following this guide to do a custom transition between two UIViewControllers that are within a navigation controller.
I'm trying to replicate the transition this 'Storehouse' app transition ,see the transition on the far left.
Notice that the transition includes the navigation bar. However, by default the transition only applies to the view UNDER the navigation bar and just crossfades the UINavigation bars between views.
I want a reference to the entire views including the navigation bar so that I can recreate this effect. I understand I'm probably seeing this behavior since they share a UINavigationController, and thus a navigation bar.
Any ideas?
Thanks!
See here
This is a much asked question here on SO btw. Maybe use the search functionality first next time? ;)
EDIT
Reviewing the transition you posted I must say it does not look like this is a UINavigationController setup. The solution I linked above works for a default setup. It looks like 'Storehouse' has put up a custom solution here. (I looks very neat though!).You will probably have to code this by yourself, i.e. fake the navigation bar.
i'm curious about what's the best way to plan the controllers for my app.
i want my main screen to have 3 button.
1) should open a nav controller with details view
2) should open a controller with other buttons that lead to others controllers
3) should open a tab bar with 2 pages ( or eventually use a switch to change page instead of the tab bar)
this is the schema of what i want
http://i59.tinypic.com/2rrvrd4.png
Is it a correct schema or i should use my controllers differently? will apple reject an apple with such schema?
thanks
As #Fogmeister pointed out in the comments, going for a UITabBarController as the main interface for your app actually seems to be a more appropriate solution here.
However, you can go with the interface that you described, but then you should keep in mind that with your current setup, you are not only using UINavigationController in the first case, but your whole navigation system is still built upon UINavigationController in the following way:
Your app has one instance of UINavigationController.
Your initial UIViewController (the one with the three buttons), is the rootViewController of your UINavigationController.
You can navigate to the other view controllers using [self.navigationController pushViewController:newViewController] (or performSegue if you prefer using Storyboards).
In the case of your third view controller, you are pushing a UITabBarController onto the navigation controller's view controller stack, this UITabBarController needs to be initialized with the two view controllers that it is going to display before it gets pushed onto the stack.