简体   繁体   English

横向模式下的shouldAutorotateToInterfaceOrientation UIToolbar将关闭1个像素

[英]shouldAutorotateToInterfaceOrientation UIToolbar in landscape mode is one pixel off

I do add a Toolbar to my view like this: 我确实将工具栏添加到视图中,如下所示:

self.myToolbar = [UIToolbar new];
    self.myToolbar.barStyle = UIBarStyleDefault;
    self.myToolbar.tintColor = [UIColor BAR_COLOR];
    self.myToolbar.frame = CGRectMake(0, self.view.bounds.size.height-44, 320, 44);
    self.myToolbar.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
[self.view addSubview:myToolbar];

In the interface builder I set fixed to top and left margin for the view. 在界面构建器中,我将视图的顶部和左边距固定为固定。 Also in the simulated metrics I set Status Bar to Black, Top Bar to Navigation Bar and Bottom Bar to None. 同样在模拟指标中,我将状态栏设置为黑色,将顶部栏设置为导航栏,将底部栏设置为无。

This works perfect in portrait mode. 这在人像模式下工作完美。 And looks like this: 看起来像这样:

在此处输入图片说明

Now when I rotate to landscapemode the toolbar gets resized and everything BUT it is off the buttom by one pixel like this: 现在,当我旋转到横向模式时,工具栏将调整大小,但一切都偏离了底部,像这样一个像素:

在此处输入图片说明

What could be the cause off this? 这可能是什么原因造成的?

The following code is working : 以下代码正在工作:

self.myToolbar = [UIToolbar new];
self.myToolbar.barStyle = UIBarStyleDefault;
self.myToolbar.tintColor = [UIColor BAR_COLOR];
CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; //get the rect of the screen 
self.myToolbar.frame = CGRectMake(screenRect.origin.x, screenRect.size.height-44, screenRect.size.width, 44);
self.myToolbar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:myToolbar];

EDIT 编辑

It is actually a bug occuring on the iOS5 simulator. 实际上,这是在iOS5模拟器上发生的错误。

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

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