Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

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

I created a tableview in storyboard, which looks good, but the start position is wrong in the simulator or device. The 'Label' should not be at the same position as the time. How could I solve it??

storyboard

enter image description here

in simulator

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...