Persistent header in app with UINavigationController - ios

I have a nice iPhone app built that uses a UINavigationController to navigate through a series of tableviews. I now want to add a persistent banner at the top of all of my views, either above the navigation bar or just below it. I do not want it to scroll with the tableview, so I do not want to make it a custom first row.
Any ideas on the best way to approach this?

What I did to achieve this was to make a new UIView for each of the views that I needed the banner on, and placed the banner in there, and the table or other view below the banner. This doesn't keep the banner there persistently through the transitions which is what I really wanted, but I was able to get a non-scrolling header above my tables.
EDIT:
The "correct" way to do this now would be to have a root view controller that consists of your header, and a container view, and then all of the navigation and content goes inside your container view. Although this does require ios6+

You could customize your navigation bar so that it displays the "classical" bar and then, above or below it, it draws your specific content. See this post for more detail.

Related

Using RealmSearchViewController with a UITableView

I'm developing my first app in swift, which has a table that shows data stored using Realm. I've managed to add stuff to the Realm and show it in a table. Afterwards I wanted to add search capability and stumbled upon these two guides: http://www.raywenderlich.com/81615/introduction-to-realm and https://realm.io/news/building-an-ios-search-controller-in-swift/. I would like to use RealmSearchViewController, but I can’t seem to fit it to my setup. I tried using a UITableViewController embedded in a Navigation Controller, but I need a button at the bottom of the screen, where the user should tap to add an entry to the list. I tried using a tableFooterView with a button, but it can only stick to the bottom of the table and not the bottom of the screen. I also tried using a Tool Bar and a Tab Bar in the Navigation Controller, but it doesn’t show as the table takes up the whole screen.
What I would like to achieve is something like Airmail for iPhone, where there’s a Tab Bar at the bottom that is hidden when the user scrolls. Above the Tab Bar I’d like a table with content from the Realm, and then a Search Bar, which is directly below the Navigation Bar. I’d like to use RealmSearchViewController as it makes searching a lot easier, but how can I adapt it to be used with a Table View and not a Table View Controller?
Any other suggestions as to how I can achieve the same functionality?
Thanks!
My recommendation would be to create a parent view controller that arranges the the view of RealmSearchViewController so that it doesn't cover the entire screen, and then arrange a UIButton at the bottom.
You can do this in a Xib/Storyboard by arranging a view and a button with autolayout and then simply add the view from RealmSearchViewController as a subview to the view in this parent view controller.

Custom View at the bottom of navigation bar

I need to add a custom view just below the bottom of navigation bar. My requirement is that when certain condition meets, I need to show a view of 80 height which needs to be sticky, for all remaining subsequent screens. Its like what music streaming apps pandora, Spotify have it when you start playing a song but it is at the bottom, but I need to have a view at the top. Any helps
I am not entirely certain about all the mechanics of how you would do it, but You may want to start by adding the view that will have this sticky content to the root viewController or navigationController, and do it like suggested in this post:
iOS Floating Video Window like Youtube App
So, this is how I solved it, but instead of custom view at top, I end up showing at bottom only, requirements changed. To do that I was maintaining a root view controller which has tab bar inside it, and it also has custom view, so it was easy to manage that by this hierarchy, as root view controller can easily show and hide the view, and also it remains persistent irrespective which tab user go. But I still don't know how to do at top, which was original requirement.

Custom UITabBarController with Scrolling

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!

Managing a subview shown within several tabs in a tabbed app

I have a tabbed iOS 5 app where I need to keep showing a certain subview when some of the tabs are tapped and become displayed. In the following mockups I try to explain what I need: most of the tabs should keep showing a same subview that is intended to show the status of something concerning the core functionality of the app, whereas there's no need to show such status indicator subview within some of the tabs (for example, a settings tab):
Some of the tabs may also allow to navigate through a hierarchy of views, but the subview must keep visible even if user navigates. How could I manage this scenario? Should I create a separated .nib and UIViewController for the subview, and add/remove it as a subview of the root UITabBarController? Or should I load the .nib from within each tab bar view controller, and handle the subview within the tab's view controller? Or is there another and better way to handle this situation?
Thanks in advance
Separate the subview class and its data model. The subview should listen to changes in the data model and possibly modify the data model. Each tab keeps its own subview, but since all subviews share the same data model, when you update one, you update all.

Designing view on top of multiple embed views

I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.

Resources