简体   繁体   English

为什么表格视图的尺寸与iPhone X〜iPhone XS Max不同?

[英]Why is the table view different size from iPhone X~iPhone XS Max?

In storyboard, I fill table view full size. 在情节提要中,我以全尺寸填充表格视图。


And I set my placeholder view height set like this. 我将占位符视图高度设置为这样。

self.placeholderView.frame.size.height = self.mainTableView.frame.height


If I launch iPhone se ~ iPhone 8 Plus, good result. 如果我启动iPhone se〜iPhone 8 Plus,效果很好。



But if I launch iPhone x ~ iPhone Xs Max, small size. 但是,如果我推出iPhone X〜iPhone Xs Max,则体积很小。

Even in the case of iPhone X, the table view itself is full size. 即使在iPhone X的情况下,表格视图本身也是完整尺寸。 But why do I get a different size when I get a table view? 但是,为什么我在获得表格视图时会得到不同的大小?
How to fix it? 如何解决?

You should use this instead, 您应该改用这个

self.table.backgroundView = yourView()

and if you want to set data back to the table just set 如果您想将数据设置回表中,只需设置

if table.backgroundView != nil{
   table.backgroundView = nil
}

I don't know if you like this idea or not but I used it every time when I change my background table view to the user that shows like no data or no internet connection. 我不知道您是否喜欢这个想法,但是每次将背景表格视图更改为显示无数据或没有互联网连接的用户时,我都会使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM