0
votes

I’m working on a project in Xcode 9.1 and a very strange problem occurs with my Table View Controller.

I need to have a table view with static cells and Xcode tells me that I can achieve this only with a TableViewController (doesn’t work with a TableView in a ViewController. Gives me errors).

I’ve embedded my TableViewController inside a Navigation Controller, but when I run the project, the table View scrolls and it’s visible under the status bar (on every iPhone, from X to SE).

I wanted to make the status bar opaque but didn’t find a way to do it. Am I doing something wrong?

My steps are:

1) Dragged a TableViewController on the storyboard

2) Embed the TableViewController into a Navigation Bar (I’ve tried also to drag the Navigation Bar directly and it comes already connected to a TableViewController).

3) Set the Cells to Static

4) Run on device or simulator.

Screenshot of my problem

2
Try to set the property "Extend Edges Under Top Bars" in the AttributeInspector to false. The property is on your TableViewController in the storyboardTMob
Are you sure those four steps are all you've done? Create a new Xcode project, follow those four steps and the status bar and navigation bar should be opaque. The table view should begin below the navigation bar. Also, I assume in step 2, you meant to say "Embed the TableViewController into a Navigation Controller" ?Craig Grummitt
@CraigGrummitt yes, I’m sorry, I meant Navigation Controller. Just edited the question. And yes, I’ve done those steps again now, and I still have the tableview scrolling over the status barMehdi_Mahdloo
@TMob if I set it to false, my status bar and Navbars becomes blackMehdi_Mahdloo
Can you post a screenshot of "the tableview scrolling over the status bar"? Or a link to a github repo with the problem? Because following those steps I don't see the problem.Craig Grummitt

2 Answers

2
votes

Solved it!

The problem was the code I wrote to hide the navigation bar hairline (the 1px line under the bar). Commenting the code make everything work fine.

1
votes

To fix your issue I think your Navigation Bar is set to hidden.
1. In your storyboard click on the navigationBar in the navigation controller.
2. Then look for the attributes section "Drawing"
3. Check to see if hidden is true.
4. If it is uncheck it. My setup has it set to false as default.

to hide navigation you need to write below code in viewDidLoad

self.navigationController?.isNavigationBarHidden = true