具有双高状态栏的 XCode Redraw 纵向布局
我的应用程序中的多个屏幕都遇到此问题,但我将解释我的主屏幕上会发生什么情况。希望解决方案不会像我想象的那么复杂。所以我的主屏幕顶部有一个徽标,下面有一个标签(标题),下面有 3 个水平按钮,最后,纵向时,设置和信息按钮分别位于左下角和右下角。为了允许横向,调整蒙版大小无法实现我想要的外观,因此我
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
使用 if 和 else 语句实现了该方法,“if”使用 CGRectMakes 绘制所有元素应该在横向布局中的位置,“else”在变回纵向风景时将它们重新绘制回原来的位置。这一切都非常有效。我记得我们必须能够处理双高状态栏,所以我模拟了它,看看它会对我的应用程序产生什么影响。当我在主屏幕上并打开和关闭它时,项目的自动调整大小(设置为根据视图顶部进行调整)工作得很好,通过稍微挤压所有内容,而不是隐藏任何内容。我可以毫无问题地关闭和打开它。
现在的问题是:
当我在不同的屏幕上打开双高状态栏,然后返回主屏幕时,不会发生调整大小,并且它会重新绘制我的屏幕全尺寸根据我前面提到的方法中的坐标和大小,因此设置和信息按钮绘制在屏幕底部的中间位置。在双高状态栏已打开的情况下,在主屏幕上从横向切换回纵向时也会发生同样的情况。
同样,我在另一个页面上的导航栏和选项卡栏之间有一个地图。当已经在页面上并打开和关闭它时,所有内容都会很好地调整大小(地图框架会改变高度,导航栏会向下移动)。但同样,当我从不同的屏幕或横向切换到该屏幕时,我遇到了问题,因为地图视图和导航栏没有适当地自动调整大小,而是部分地推到了选项卡栏后面,从而模糊了作为理由的谷歌商标用于应用程序拒绝。
抱歉啰嗦了,但我想清楚地描述一下是什么情况导致了这个问题。任何想法将不胜感激,因为我真的不知道如何解决这个问题。
I'm having this issue with several screens in my app, but I'll explain what happens to my home screen. Hopefully the solution isn't as complicated as I'm thinking it will be. So my home screen has a logo at the top, a label(title) under that, 3 horizontal buttons under that, and finally, settings and info buttons in the bottom left and right hand corner respectively when if portrait orientation. In order to allow for landscape orientation, resizing masks were not able to achieve the look I wanted so I implemented the
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
method with an if and else statement, the "if" uses CGRectMakes to draw all of the elements where they should go in landscape layout, and the "else" redraws them back to their original places when changed back to portrait landscape. This all works very nicely. I remembered that we had to be able to handle the double high status bar, so I simulated it to see what it would do to my app. When I am on the home screen and toggle it on and off, the autoresizing of the items(which are set to adjust according to the top of the view) work nicely, by slightly squishing everything down a bit, and not hiding anything. I can toggle it off and on with no problems.
Now here's the problem:
When I have the double high status bar toggled on while on a different screen, then go back to my home screen, the resizing doesn't happen, and it redraws my screen full size according to the coordinates and sizes I have in the method I mentioned earlier, so the settings and info button are drawn halfway off the bottom of the screen. Same happens when switching from landscape back to portrait on the homescreen with the double high status bar already on.
Similarly, I have a map between a nav and tab bar on another page. When already on the page, and toggling it on and off, everything resizes nicely(the frame of the map changes height and the nav bar moves down). But again, I have a problem when switching to that screen from a different screen or from the landscape orientation, because instead of autoresizing appropriately, the map view and nav bar get pushed down behind the tab bar partially, obscuring the google trademark which is grounds for app rejection.
Sorry for the longwindedness, but I wanted to clearly describe what circumstances cause this problem. Any ideas would be greatly appreciated as I don't really have any idea how to approach this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在尝试自己找出这个问题。我认为发生这种情况是因为自动调整大小蒙版仅在调整视图大小时使用,而不是在将新视图添加到场景时使用。
对我来说,我想要一个从笔尖加载的设置视图,并将其添加到其他所有内容之上。如果添加视图时双高栏有效,它将超出屏幕底部。要修复它,您必须在加载视图时自行设置视图的大小和位置。这是我工作的“转到设置”按钮背后的代码:
重要的一行是:
它看起来被归类为“调整大小”,因此应用调整大小掩码规则。后来我添加了过渡动画,它仍然工作得很好。
注意:此方法位于视图控制器中。
I've been trying to track down this problem myself. I think this happens because the autoresizing mask is only used when views are resized, and not when a new view is added to the scene.
For me, I wanted a settings view loaded from a nib and added on top of everything else. If the double-height bar was in effect when the view was added it would run off the bottom of the screen. To fix it you have to set the size and position of the view yourself when you load it. This is the code behind my working 'goto settings' button:
The important line being:
Which, it would appear, classifies as a 'resize' and so the resizing-mask rules apply. I later added animations for the transition and it continues to work just fine.
Note: This method was in a View Controller.