heyred
heyred

Reputation: 2051

Xcode tableview hidden behind navigation bar

Can anyone please tell me how to fix the following issue. I am building an iPhone app using Storyboard. I have a Navigation Controller as root view and off that a view controller. On this I have a few buttons that when clicked takes you to a table view controller. All fine and well, but when I link the buttons to their respective table views, the top navigation bar obscures the top cell in the table view controller.

Does anyone know why this is happening and how I can fix it? Also it seems to have thrown off my layouts from the view controller from which they inherit.

See attached image for a better explanation perhaps.

enter image description here

Upvotes: 2

Views: 4688

Answers (4)

Javier Melendez
Javier Melendez

Reputation: 1

You just need go to the Navigation Controller properties, then Simulated Metrics, and change the Top Bar to be a Transluscent Navigation Bar WITH PROMPT. And that should be it. No need for that extra UIView

Upvotes: -1

Justin Whitney
Justin Whitney

Reputation: 1272

Since I wanted to keep the translucence, I just added a UIView between the navigation controller and the prototype cell (width of the view, height 60). That way the first cell in the table starts beneath the navigation bar but I can still see the scrolling underneath.

Upvotes: 0

GayleDDS
GayleDDS

Reputation: 4533

This is a bug/feature in IB when you use a translucent navigation bar, the content view runs under the navigation bar. For non transparent bars the content view begins after the bar. If your content view is a UIScrollView (UITableView is a descendent of UIScrollView) the content will be automatically scrolled so as to not be hidden under the navigation bar. So the problem only exist in IB when you run the app everything should be ok.

Upvotes: -1

Mick MacCallum
Mick MacCallum

Reputation: 130193

I believe this is the intended behavior when using the translucent navigation bar. It's semi transparent specifically so that you can see items pass behind it (e.g. a table scrolling). If you don't want this, changing the navigation bar's style to opaque should solve the problem.

Upvotes: 6

Related Questions