简体   繁体   English

iOS 7 addSubview为我的UIView添加了额外的长度,这是为什么?

[英]iOS 7 addSubview adds additional length to my UIView, why is this?

Within my app I have a view controller within a window that adds some subviews when they are required. 在我的应用程序中,我在一个窗口内有一个视图控制器,可以在需要时添加一些子视图。 All the subviews appear using IBActions and the following code: 所有子视图使用IBAction和以下代码显示:

[self.view addSubview:myViewIWantToAdd];

All of them appear with the correct dimensions and positioning apart from one view. 所有这些视图均以正确的尺寸和位置显示(与一个视图分开)。 The method seems to add an additional 20 pixels to the length on the view attempting to be displayed to produce the following effect: 该方法似乎在试图显示的视图长度上增加了20个像素,以产生以下效果:

http://i.stack.imgur.com/th11f.png http://i.stack.imgur.com/th11f.png

As you can see from the image that the bottom letter tiles extend below the screen boundary by an extra 20 pixels. 从图像中可以看到,底部的字母图块在屏幕边界下方延伸了额外的20像素。 I can fix it by reduce the size of the view from height 568 to 548. However in doing so creates a peculiar effect. 我可以通过将视图的大小从568减小到548来修复它。但是,这样做会产生奇特的效果。 When the height of the UIView is set at 548 the touchable (user interaction) area also reduces by 20 pixels. 当UIView的高度设置为548时,可触摸(用户交互)区域也会减少20个像素。 This means that users cannot select the bottom half of the bottom letter tiles. 这意味着用户无法选择底部字母图块的下半部分。 At this stage I am pretty lost as I am implementing the UIView just like any other UIView within the app which don't have any problems at all. 在这一阶段,我就像在实现应用程序中的其他任何UIView一样实现UIView时完全迷失了,根本没有任何问题。 How can I fix this / what am I doing wrong? 我该如何解决/我在做什么错?

PS I never had this issue in iOS 6, I believe it's something to do with iOS 7. PS:我在iOS 6中从未遇到过此问题,我认为这与iOS 7有关。

In ios 7, your window is beneath the status bar , so your window's height will be 20 point higher. 在ios 7中,窗口位于状态栏下方,因此窗口的高度将高20点。

You can adjust the subview's frame and set appropriate autoresizingMask property of view to solve it. 您可以调整子视图的框架并设置视图的适当autoresizingMask属性来解决它。

If you want to make your app meet ios7 appearance, see the link 如果要使您的应用符合ios7的外观,请参见链接

请在您的设备上进行相同的测试。

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

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