简体   繁体   English

UIview布局无法针对iPhone视网膜4英寸屏幕自动调整大小

[英]UIview layout not autosizing for iPhone retina 4 inch screen

Xcode 5 storyboard app. Xcode 5故事板应用程序。 When I tap on button in the app, choosing a property - UIView opens, but only shows the correct layout for the first View. 当我点击应用程序中的按钮时,选择一个属性-UIView打开,但仅显示第一个View的正确布局。 When swiping left/right - the layout of all views is fine. 向左/向右滑动时-所有视图的布局都很好。 The problem only happens when I tap on any button, except the first one. 仅当我点击除第一个按钮以外的任何按钮时,才会发生此问题。 All the settings for all views and all code in .h and .m files are equal. .h和.m文件中所有视图的所有设置以及所有代码均相等。

I use iCarousel for swipes. 我使用iCarousel进行滑动。

Screenshots will help you to understand the problem better: 屏幕截图将帮助您更好地理解问题:

  1. Right: ![Correct layout] http://i.stack.imgur.com/b0HEP.jpg 右:![正确的布局] http://i.stack.imgur.com/b0HEP.jpg

  2. Wrong: (see blank space at the top and bottom) ![Incorrect one - has to look like Pic.1] http://i.stack.imgur.com/xqTmH.png 错误:(请参见顶部和底部的空白)![不正确-必须看起来像Pic.1] http://i.stack.imgur.com/xqTmH.png

    I don't want to mess with auto layout because scrollviews doesn't work properly with it. 我不想弄乱自动布局,因为scrollviews无法正常使用。 Any help would be appreciated! 任何帮助,将不胜感激! Thanks! 谢谢!

Check out if this works. 检查是否可行。 I too had a issue of same kind where the position of top and bottom margin has shifted. 我也遇到过同类问题,其中上边距和下边距的位置已发生变化。 I used this in viewDidLoad method. 我在viewDidLoad方法中使用了它。

if( [self respondsToSelector:@selector(setEdgesForExtendedLayout:)] ) 
{    
    self.edgesForExtendedLayout=UIRectEdgeNone; 
}

or else set frame for iPhone retina 4 inch screen like this   
if(IS_IPHONE_5)
{
     tableView.frame = CGRectMake(0, 0, 320, 560); // something like this in DidLoad method or in viewWillAppear method
}

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

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