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

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:

Related

UIView inside UIScrollerView displays with -64 offset

I'm trying to create a form that will be larger than the screen size and I've decided to use a view inside a scrollerview, then I'm adding the rest of the UI widgets (textfields, buttons, etc.) inside the view.
The view displays and scrolls, but no matter what I try, it displays with a vertical offset of -64 below the navigation controller bar. Once there the view will happily scroll up down.
I want the view to anchored at the top, just below the navigation bar, and then scroll down.
I am using IB.
Lots of time researching and not many answers that have worked for me. UIScrollView seems to be like one of those dirty secrets the whole iOS world seems to avoid....
Thank you for your help.
You can fix this in the storyboard
1- Select the view Controller
2- GO to attributes inspector
3- Uncheck adjust scroll View insets
For your view controller, in the storyboard uncheck the option to extend edges under top bar.

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

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?

How to create space between UINavigationBar and top of UITableView

I have a UITableView in my storyboard. I put a navigation bar at the top of the view. However the title seems to close to the top of the view near the time and battery. Is there any way to create spacing like in the view to the left of that one? I tried simply dragging the navigation bar down but it seems pinned to the top of the view. Any help is appreciated. Thanks!
If you are using autolayout (which I very much recommend), you are just missing a Vertical Space Constraint between your container view and your table view.
See the size inspector (as shown below) for a list of constraints on a UI element, or browse your Document Outline for missing constraints.

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.

Navigation bar View Controller is twice the size as others

I have a multiple View Controllers embedded in Navigation Controller and one of my navigation bars is twice the size(extends down twice as much) as every other one. I want all of these bars to be the same size, but can't find anyway to change the size in Inspector. There are no bar buttons on this Navigation Bar. Any ideas for a quick fix w/o having to rebuild this VC?
Thanks
Default UINavigationBar have a height of 44 points and it can't be changed. I think you have a constraint issue: select your wrong sized UINavigationBar and on the top right corner, in the "utilities", select "size inspector". Then, have a look at the severals constraints, edit and/or delete some.

Resources