简体   繁体   中英

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:

[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:

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. I can fix it by reduce the size of the view from height 568 to 548. However in doing so creates a peculiar effect. When the height of the UIView is set at 548 the touchable (user interaction) area also reduces by 20 pixels. 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. 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.

In ios 7, your window is beneath the status bar , so your window's height will be 20 point higher.

You can adjust the subview's frame and set appropriate autoresizingMask property of view to solve it.

If you want to make your app meet ios7 appearance, see the link

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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