简体   繁体   English

iOS Xcode子视图无法覆盖真实设备中的所有屏幕

[英]IOS Xcode Subview does not cover all of the screen in real device

I am new to Xcode and IOS programming and am creating an app using Swift . 我是Xcode和IOS编程的新手,并且正在使用Swift创建应用程序。 I have ran into a peculiar issue when I run my app on the emulator the dimensions look good (height and width) however on the real device they are too short in both length and width. 当我在模拟器上运行应用程序时,遇到了一个特殊的问题,尺寸看起来不错(高度和宽度),但是在实际设备上,它们的长度和宽度都太短了。 What I want is to get my subview to cover the screen completely on my I-phone device like it does on the emulator .The subview is the orange background UIColor that you see below it starts right underneath the UISearchBar and it is supposed to cover the whole area below it .You can see the difference below: the 2nd image is the emulator notice how the subview width is the same as the UISearchBar and the 3rd and last image is of my real device and see how the SubView width is not as wide as the searchBar . 我想要的是让子视图完全覆盖我的I-phone设备上的屏幕,就像在模拟器上一样 。子视图是橙色背景UIColor,您在其下方看到的该颜色从UISearchBar的正下方开始,并且应该覆盖您可以看到下面的区别:第二个图像是模拟器,请注意子视图的宽度与UISearchBar相同,第三个和最后一个图像是我的真实设备,并查看SubView的宽度不那么宽作为searchBar。 Any suggestions would be great . 任何建议都很好。 Also as I stated before the Orange background is a View under the main View and it is called Registration_View . 就像我在橙色背景之前所说的那样,主视图下还有一个视图,它称为Registration_View I want to make it as long and wide as the Original view but start it under the SearchBar which I already have working. 我想使其与原始视图一样长和宽,但是要在我已经在使用的SearchBar下启动它。 Any suggestions would be great. 任何建议都很好。 This is what I have in my code and I have auto-layout on 这就是我的代码中的内容,并且在

  @IBOutlet weak var Registration_View: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()

        Registration_View.backgroundColor = UIColor.orange
    } 

在模拟器上的外观

How it looks on the emulator which is great 在模拟器上的外观很棒 在模拟器上的外观 How it looks on my device width and length are short 我的设备宽度和长度看起来很短 设备上的外观如何

您必须使用自动布局并设置视图约束,以使Superview的前导,尾随和底部的边距为0。

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

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