Animation bug with always displayed large titles after popping view controller - uinavigationbar

I wanted to use the new Large Titles with largeTitleDisplayMode set to .always but got some strange animation issues while popping the pushed detail controller if the root UITableView's contentOffset.y is positive aka scrolled.
So this is how it should work:
And this is how it works after scrolling:
I guess it's a bug, but maybe anyone have a workaround till it's fixed?
To reproduce, create a new sample project, open Storyboard and do the following:
Add Navigation Controller and tick it's Navigation Bar's Prefers Large Titles value
Select it's Root View Controller and set it's Table View's Content to Static Cells.
Add many static cells or make then big enough, so your Table View become scrollable
Add a View Controller as detail view controller and setup the Show segues
Setup the Navigation Item's Large Titles property to Always for both view controller
Run the app, scroll to the bottom, perform a show/push segue and pop back

Related

How to fix incorrect (small) view on my main storyboard

So In my main storyboard one of my view controllers view is smaller than it should be, making that part of the UIView untouchable to the users... I don't know if its a tool bar or some weird inherited view from the previous view controller as it does have a relationship to the previous view controller
tried removing tool bar, I even put my tableview over top of the view making it bigger, but it is unusable on the iPhone after the build
I just need it removed, its a grey bar
I am going to assume that gray is being passed over to your present view controller, I would remove the segue to check if the view updates its constraints, if so remove the previous view controller and embed it to the previous to remove the bar

Navigation bar breaks in Tableview / detail view inside Tab bar controller

This is a bit of a tricky one to explain here so I'm hoping the screenshot of the storyboard of the app I'm trying to build helps to clarify what I'm trying to do.
Basically the apps starts with a nav controller and table view, when you click on a cell in the table view you go to a tab bar controller with three tabs, each tab view has its own navigation controller and subsequently there is a navigation bar on each of them, so at this point there is a back button on all tab views which takes us back to the initial table view.
The first tab view simply has some text, the next has a table view with several table cells and the last has a map view with several markers. Both the table cell and the map markers link to a detail view via a navigation controller which shows more detailed information (both via named segues). It's at this point of clicking through to the detail view where the navigation is breaking, the detail page shows no navigation bar although it is there as the title text is set, but there is no back button and it seems that the navigation context / hierarchy has been broken here somehow. The appearance of the storyboard also reflects this as it shows no Back button on the navbar on the navigation controller or the Detail view.
Without initially getting into the code in any real way I am just trying to see if there is any significant reason why these type of structure / hierarchy is just now going to work. So, my main question is does this storyboard structure seem like the correct way to go about what I'm trying to do?
Here is the storyboard:

Xcode 6 - Swift - Custom Tabbar with Navigation

I'm trying to create a tabbed application with navigation elements inside the tab bar, as seen in the picture below (the red bar) using Swift/XCode 6.2. Basically those three icons in the middle will direct the user to different view controllers. The other two icons would be context-based. For example, on a table view page you would see the menu icon and add new icon as seen in the image. However, clicking on a row would change the menu icon to a back icon, and the add icon to something else.
That's the general idea, but I'm having a very hard time implementing something even close to this. The first issue is that whenever I embed a view in a Tab Bar Controller, I can't move the tab bar to the top. However, when I create a custom UITabView in a View Controller, Control + Click and dragging a Tab Bar Item to another view doesn't create a segue. I haven't even begun to tackle having the navigation elements inside the bar.
I guess what I'm asking is just for a little guidance on what route to take to tackle this. I'm assuming I can't use a Tab Bar Controller or Navigation Controller because it doesn't seem like I can customize them all that much. So custom Tab Bar and Navigation Bars, and then implemnt the segues and button changes programmatically?
Thanks.
I will try to guide you from an architectural perspective (so you won't find much code below).
Using a UITabBarController
In order to achieve what you are suggesting, you are right you cannot use a UITabBarController straight away, among several reasons, the most immediate one is that they are meant to be always at the bottom and you want it in top (check Apple's docs). The good news is that probably you don't need it!
Note: If you still want to go with a UITabBarController for whatever reason, please see #Matt's answer.
Using a UINavigationController
You can use a UINavigationController to solve this task, since the UINavigationBar of a UINavigationController can be customized. There are multiple ways on how you can organize your view's hierarchy to achieve what you propose, but let me elaborate one option:
To customize a UINavigationBar's to add buttons, you just need to set its navigationItem's title view:
// Assuming viewWithTopButtons is a view containing the 3 top buttons
self.navigationItem.titleView = viewWithTopButtons
To add the burger menu functionality on a UINavigationController you can find several posts on how to do it and infinite frameworks you can use. Check this other SO Question for a more detailed answer (e.g. MMDrawerController, ECSlidingViewController to mention a couple).
About organizing your view hierarchy, it really depends on if when the user taps one of the main top buttons, it will always go to the first view controller in the new section or if you want to bring him back to the last view in the section where he was.
3.1 Switching sections displays the first view of the new section
Your app's UIWindow will have a single UINavigationController on top of the hierarchy. Then each of the 3 top buttons, when tapped, will change the root view controller of the UINavigationController.
Then, when the user changes section, the current navigation hierarchy is discarded by setting the new section view controller as the UINavigationController root view controller.
self.navigationController = [sectionFirstViewController]
3.2 Switching sections displays the last displayed view in the new section
This will require a slightly modified version of the above, where your each of your sections will have its own UINavigationController, so you can always keep a navigation hierarchy per section.
Then, when the user taps one of the top buttons to switch section, instead of changing as previously described, you will change the UIWindowroot view controller to the new section's UINavigationController.
window.rootViewController = sectionNavigationController
Using a custom implementation
Of course, the last and also very valid option would be that you implement yourself your own component to achieve your requirements. This is probably the option requiring the biggest effort in exchange of the highest customizability.
Choosing this option is definitely not recommend to less experienced developers.
I'd like to take a stab at this--I think it is possible to use a tab bar controller here.
Your topmost-level view controller will be a UITabBarController with a hidden UITabBar.
Each tab is contained in a UINavigationController.
All view controllers in the navigation controller will be a subclass of a view controller (say, SwitchableViewController).
In SwitchableViewController's viewDidLoad, you set the navigation item's title view (i.e. whatever's at the center; self.navigationItem.titleView) to be the view that holds the three center buttons. Could be a UISegmentedControl, or a custom view.
Whenever you tap on any of the buttons, you change the topmost UITabBarController's selected index to the view controller you want to show.
Issues you may encounter:
Table views inside tabs will have a scrollIndicatorOffset at the bottom even if the tab bar is hidden.
Solution: Play around with the automaticallyAdjustsScrollViewInsets of the tab bar controller, or the inner view controller. https://stackoverflow.com/a/29264073/855680
Your title view will be animated every time you push a new view controller in the navigation stack.
Solution: Take a look at creating a custom transition animation for the UINavigationController.

UITableViewContent Inset messed up on iOS 8

I have a navigation controller with a UITabBarController as the initial view controller. Within that, I have two UIViewController's as sub-viewcontrollers in the tab bar controller. Both of my view controllers have UITableView's in them. The first one always looks fine. However, the second view controller always has a messed up content inset. I don't know why because there doesn't seem to be any difference in the way I setup my table views. I can manually set the content inset in viewDidLoad, but there's got to be a better way since it's working by default in the first view controller.
This is the first table view. As you can see, the the content offset looks fine.
Something to note: when opaque navigation bars are turned off, the issue goes away.
This is the second table view. As you can see there is a table view cell underneath the navigation bar.
I fixed the issue by changing the structure of my view hierarchy. Apparently I should not of had a UINavigationController as the initial view controller, but rather had the UITabBarController as the initial view controller and from there have UINavigationControllers within the tab bar where needed.

TableView as subview with navigation controller

I would like to have a view (one of five tabbars) with some subviews (labels, images and such) including a table view, so that the table view will only take up half of the screen (similar to this thread Add tableview as subview to view?). I have set up the views controller as tableview delegate and data source, but how can I use navigation with this table view (uinavigationcontroller)?
Clarification:
I started out with a tab bar based app, and wanted to have one of the tab bar views to have some labels in to top and a table view in the lower half of that view. I solved it myself, see below
This was of course simpler than I thought it was. I set up a tab bar controller with some tabs (with individual view controllers). I embedded one of the view controllers in a navigation controller (using the menu Editor -- Embed in -- Navigation Controller). Added the labels and a uitableview (through Storyboard) to the view and hooked up outlets for the labels and the table view, as well as setting the view controller as delegate and data source (UITableViewDelegate, UITableViewDataSource).

Resources