IOS/xcode: Tableview does not fill up view when using SearchDisplay - ios

I have several different tableviewcontrollers connected to tabs. All were created in storyboard.
For all but one, I don't have a search bar. For one, however, I do have a search bar. When you view the one with the searchbar the table view does not take up the whole space at the bottom. At the top it shows the search bar as you would expect. But at the bottom, it leaves empty space.
In the measurement inspector for the storyboard, the view controller appears to have the same dimensions 600x600 as the tableview for the other view controllers.
Some answers suggest that the table row height may differ with the search bar controller but I tried changing that and it did not have any effect.
Can anyone suggest what might be causing this problem?

Related

iOS/autolayout/storyboard: Apply constraint to Searchbar in tableview

In order to have a tableview adapt to screen size, I have constrained it to its parent view. However, now when I do this, the Search bar--which used to fill up the whole navigation bar, leaves a space to the right and is in fact smaller than the tableview.
When I try to apply constraints to the search bar, however, they don't take. If I control drag from the searchbar to the container view in storyboard, there are no constraint options, only gives the a delegate option. And if I click on the auto layout buttons, they don't allow you to set any constraints for the search bar. So at this point I am stuck.
This is how I want the search bar to look:
This is how it now looks.
Can anyone suggest how to make the search bar look like the first example--the same width as the navigation bar. Thank you.
Edit:
Storyboard:

Placing items above table view in a table view controller that do not scroll Swift

This issue is something I have been struggling with for a while and have been able to get around for the most part by using was seem like hacky techniques but I am needing a better way to accomplish this now.
My question is how do you add UI elements above a table view (in a table view controller) and make them stick to the view (the should not scroll with the table view). For example adding a navigation bar is simple because you can just embed in a navigation controller to the table controller. But what if you want to add say a tab bar below the navigation bar but above the table view? So that the table view scrolls and the tab bar sticks to the bottom of the navigation bar and does not scroll with it.
Ive tried to do this by placing it in the storyboard just below the navigation bar and just above the tableview but it just scrolls with the table.
Any help on this is very much appreciated!

Add a UIImageView to the back of NavigationBar (NOT background image)

I am trying to add a UIImageView to the back of a navigation bar.
The reason is because I want to create a UITableView whose navigation bar is actually a picture (with back button on the left) but I want the picture to scroll with the tableview and when the picture is fully scrolled out. The navigation bar is shown as per normal.
My solution to this problem:
Add a UIImageView to the top of the UITableView and make the navigation bar transparent. Set a contentOffset for the UITableView which is a subclass of UIScrollView so that when the view is presented, it looks like the picture is filling the navigation status bar.
Problem:
If I scroll up, instead of bouncing back, the transparent status bar is shown (with a color of the background as it is transparent).
Possible way to solve this new problem:
I was thinking of trying to limit the ScrollView size to get around with problem but failed.
So I feel is it possible to add the UIImageView to the "back" of the navigation bar so that it is there without any offset? Since that way, my life will be much easier.
Any suggestions on solving this or another new approach to get the same UI/effect?
Related question.
I would do this by adding either a table header or cell at the top of the table which contains your image.
Create the table view so that it extends all the way to the top of the screen. Extend Under Top Bars option. I have not done this with a UITableViewController but I have done this with a UITableView embedded inside a UIViewController's view with the top constraint set to 0 for the view rather than the top layout guide.
Now when you run this your table will fill the whole screen and the top header or cell will be at the top showing your picture.
When you scroll you can either use the UIScrollViewDelegate to detect the movement or implement tableView:didEndDisplayingCell:forRowAtIndexPath:
I'm not 100% sure when you want the navigation bar to go non clear. If its when the image goes off screen then didEndDisplayingCell should be good. If its when the cell bottom passed under the bottom of the navigation bar then scroll view might be your only option.
This will also bounce as you expect when you pull down and it should snap back to the top.
Hope this helps.

UITableView Content inset unexplainable behaviour

I have a View Controller with UITableView declared in storyboard. The View Controllers has "Under top bars" option selected (Edge Rect). Normally the view looks like the below image.
There is no gap between the cells of the tableview and navigation bar.
The filter in the right bar button item presents filter view controller modally and
when returning back (dismiss), there is content inset (additional) added (by I don't know who). The final looks like this.
I have tried to set content inset in viewWillAppear, viewDidLayoutSUbviews etc. But nothing seems to work. Has anyone ever come across similar kind of problems? How can I remove this contentInset.

Empty navigation bar appearing in subview

I am trying display a UITableView within a larger UIView in an iPad app, mainly because the data is pretty sparse and I'd like to have the table be a smaller area over a background image, rather than taking up the whole screen. The parent UIViewController is correctly set as the table data source and delegate, and the table looks/functions like it should. The whole view is embedded in a navigation controller; the overall UIView shows a navigation bar, as it should, that I can configure normally.
The problem is the UITableView subview also shows blank space at the top for a navigation bar--empty space above the first cell--and I can't figure out how to get rid of it. I know the space is related to the navigation controller, because when I delete the embed link in the storyboard, the space goes away. The table view doesn't present a UINavigationBar property or any other navigation-related properties that I can try to nullify.
I would post a screen shot but I don't have the rep yet.
Can anyone explain where the space is coming from and how to nix it?
I suspect the answer is related to the Top Layout Guide for the view, but I can't diagnose the specific problem.
Here's a workaround from the storyboard: Insert a UIView in the scene, then drag the UITableView into it as a subview. Check the box for the new UIView's "Clip Subviews" in the attribute window, and then use it as a mask, basically, to cover the undesired top margin of the table view. It works and doesn't require any coding, but there has to be a better way.

Resources