Start Position of Table View Is Wrong in Simulator, and Is Not The Same in Storyboard

start position of table view is wrong in simulator, and is not the same in storyboard

Simulated metrics are just that. Simulated. They're useful to set to how the view will actually display in order to help set up the look in the storyboard, but whether or not a navbar or tabbar shows up in the actual program is irrelevant to whether or not you've selected it as a simulated metric on the storyboard.

In this case, you're probably using constraints, and setting the label's y origin to be 0 pixels below the container view. When you use the simulated storyboard metrics, this puts the label just below the navbar that you're simulating on the storyboard. But in your actual project, you've done nothing to include a navbar on this scene, and your label is appearing at the top of the view controller.

You can either learn how to prevent the status bar from displaying... or you can move the label's y origin to being a 20 pixels down (the height of the status bar).


I can provide more help if you provide more details on how you're doing your layout (autolayout?), and exactly how you want it to look. But I'd start by leaving ALL of the simulated metrics on inferred and only ever explicitly change a simulated metric after you've written the code to programmatically add/remove one of the features you can change via the simulated metrics.


If you take nothing else away from this answer, please understand this: Selecting an item from a simulated metrics dropdown menu only changes how the view appears in the storyboard and doesn't change what will actually display in your app.

Main storyboard and Simulator shows different views

You have to connect the dataSource and the delegate to the view controller (or the handler for achieving it).

Programmatically:

myTableView.dataSource = self
myTableView.delegate = self

Or from the IB:

Sample Image

ios - simulator looks different from the layout on the storyboard screen

It looks like you are using Autolayout, and all your buttons except Investment has a Top constraint while Investment has a Bottom constraint, causing Investment's distance to bottom to stay the same when the screen grows taller.

Click on Investment button, click [Editor -> Pin -> Top space to Superview] in the top menu.

Click Investment button again. Click the second tab from the right in the right panel (the one where you can set frame). Look for a Top Space to Superview constraint, right click and delete. If there isn't one, then XCode did its job. Try running simulator again.

Edit: I just want to say that XCode has a habit of adding Top constraints for you when the view you just dragged into the xib is in the upper half of its container, and Bottom constraints when it's in the bottom half. I know XCode is trying to help but it drives me crazy sometimes.

Why isn’t the table view from a new View Controller not showing? Swift

I think you identified one of the issues already. Your code in func viewDidLoad() async will never be executed, because no-one calls it. By adding async you are not overriding the original UIViewController method anymore. (see https://developer.apple.com/documentation/uikit/uiviewcontroller/1621495-viewdidload)
Can you remove async and override it again? I think that should at least execute the code and you should see your print statements.

iOS: Problem with my ViewController containing a TableView in a Tab Bar that is displaying in black or with the size bad displayed

You should use the navigationController for each view controller of your tab bar because it is a bug in the storyboard that haven't been resolved until today

1/ Put the line self.definesPresentationContext = true in each view of the tabbarviewcontroller

2 / Editor/Embed/NavigationController for each view of the tabBarViewController

3 / Remove "Show Navigation Bar " for each Navigation Controller of all the viewControllers of the TabBarViewController

4 / Instead of

let vc = self.tabBarController!.viewControllers![1] as! YourViewController

Put this line :

        let nc = self.tabBarController!.viewControllers![1] as! UINavigationController
let vc: YourViewController = nc.viewControllers[0] as! YourViewController

5 / resolve all the constaints issues (in red, and in yellow in the storyboard)

6 / Remove the app before compilation on simulator or device

7 / Before the compilation, do a hard clean (Cmd + option + Shift + k)

8 / optional : in some case, close XCode, and relaunch it

UITableView embedded in other view has wrong position of section header

This can be fixed by unchecking the "Under Top Bars" box in IB for the controller that has the container view in it, not the table view controller. It doesn't seem correct that you should have to do this, since, you would think that having the main view (in the container controller) extend under the navigation bar wouldn't make the embedded table view behave the way it does.

Table View Cell not become visible on device

Select static cells from content

Sample Image

to set height

Sample Image



Related Topics



Leave a reply



Submit