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.
Related
In the youtube app there's a possibility to collapse video into a small preview window with a playback and controls while you navigating in the different parts of the app. By tapping on the window you can always switch to full screen mode again.
I wonder: what't the best approach to implement similar functionality? For now I see few options but I'm not very well aware of the implications of these options.
Note: I have an iPhone tabbar based app.
Create a popover modal view controller, that is presented on top of current navigation stack in a current tab
Create a view and stick it to the bottom of the screen.
Create a view in bounds of a tabbar controller
Create a modal view controller embedded in tabbar controller.
Just from the list I suspect that using a specialized UIView (2) would be the worst possible way to do this. But I don't know about the rest. Any advice would be greatly appreciated.
I have a simple Navigation View Hierarchy that has 2 views it goes between. I wanted a customized navigation bar, so I have the default one hidden, and I've implemented a Container View which is shared between the 2 views in the nav hierarchy.
Everything works as I want it to, except when I segue to the lower or higher view the top bar appears slides away and reappears on the new view. I would like it to appear stationary when I push or pop to other views in the hierarchy.
Is there an easy way to do this? Or should I delete my custom shared Container View and try to make this work with the Navigation Bar (which I have currently "hidden")?
I had to do this for a client once. The way we did it was, like you said, make an encompassing view controller that housed a container view. Within this container view, we embedded a UINavigationController and would manually pop and push UIViewControllers to its navigation stack. Of course you want to hide the UINavigationController's nav bar.
It sounds like you sort of implemented this, but instead you just embedded a plain old view controller inside your custom navigation controller, and then segue to another view controller that is also embedded in the custom view controller? Ideally you want one instance of this custom nav controller with an embedded UINavigationController. I believe you will have to do all the view controller transitions programmatically.
Opinion: Personally, I would recommend against doing this. I believe that an app should feel like an extension of the OS it's on. A user should feel it's a part of their phone. Using the native navigation bar also decreases the level of effort a user is required to put forth to understand your app.
I know you're thinking "but it's just a nav bar" but we're talking about the same people that will potentially uninstall an app if it takes longer than 2.5s to load.
I wanted a customized navigation bar, so I have the default one hidden
That's your mistake. The way to get a customized navigation bar in a UINavigationController interface is to initialize it with init(navigationBarClass:toolbarClass:). Now the built-in navigation controller is using your navigation bar! And from there on, all will be well.
https://developer.apple.com/reference/uikit/uinavigationcontroller/1621866-init
I am developing an application that requires a scrolling UITabBarController. The customary 5 tab items max with the 5th being the More.. tab just won't do. I have found some pretty great third party classes such as https://github.com/Marxon13/M13InfiniteTabBar and they are great and have the functionality I would like but still, things aren't perfect. When I rotate my device to landscape things become glitchy.
Basically, I am fed up and want to create my own custom UITabBarController with scrolling..how would I go about doing this? I understand I would most likely put a UITabBar within UIScrollView but I am lost without a detailed tutorial of sorts..
Any help would be greatly appreciated! Thanks!!
The way I would approach this is to avoid modifying the UITabBar, since it is highly specialized, and create a UIViewController subclass that will provide this functionality for you. This view controller should have a container view (take a look at this Apple documentation for more detailed information) that will have each child view controller's content view.
For the actual tab bar itself, you have a few options depending on what you similar you want it to the standard UITabBar.
You could have a super basic tab bar that consists of a UIScrollView with standard UIButtons that change/load the correct content view controller. Creating the tab bar would be then easy, simply add the buttons to the scroll view inside some type of loop (you could have the x positions be a multiple of the tab index to make positioning easier). UIButtons have support for a selected button state that you can use. You can change the scroll view's background.
You could have a fancy tab bar which is constructed essentially like the above, but by having a custom UIButton subclass instead of a standard UIButton. This will allow you to implement a more intricate design (i.e. with and more customized touch handling.
Tips:
Use [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] to have your tab images tinted like the standard tabs when selected.
Design the basics of your custom view controller in your storyboard. It is really easy to add the child container view and the scroll view this way.
Hope this helps!
I have a large navigation menu, like a website header(Top logo, Bottom some menu buttons.) and this navigation menu must shown in every view of my application (like a masterpage, header(this navigation) will be static but content will change). What is the best way to represent this menu in my application?
I thought UINavigationBar may be appropriate but I am not sure about it. Can I customize it that much?
totally depends on how much is 'that much'.
you can use UIToolBar for more customization that what UINavigationBar allows, but you'll have to do some extra work in getting that functionality to match that of a nav bar,
or use a customViewController that has this largeNavigationMenu, and use it as a baseClass for all viewControllers you are using in your app.
You basically need to use some kind of container controller. Either a UINavigationController, a UITabBarController or maybe something custom like a drawer menu controller. Depends on the app design.
Hope there is not an answer yet (I've checked). Can I introduce a login View in my application that enables a SplitView by using a button or something?
I've checked MGSplitViewController, but I'd like to use something more light and minimal.
If it's not possible, can I introduce a login View in my DetaiView that enables a TableView?
You can transition between arbitrary view controllers in iOS. The usual ways are using modal presentation (I like to present splash screens with a cross-dissolve animation to the root view controller of the app), or pushing/popping with navigation controllers. You can also programatically swap between multiple views in a view controller via setting the "view" property.