I have a UIViewController with a UITableView and a UISearchBar inside. As soon as the searchbar becomes first responder, there's a small gap between the searchbar and the tableview.


There's no gap when the UISearchBar is a subview of the UIViewController view instead of being a subview of the UITableView.


Obviously, one issue with that approach is that the searchbar stick to the top and doesn't scroll along with other cells, which is not desired.
Any ideas?
Edit:
Two first images correspond to the UISearchBar being a child of the UITableView, where the gap is occurring.
Last two images correspond to the UISearchBar being a child of the UIViewController view, in which case there's no gap.