Iphone 横向模式下的AutoRotateTointerFaceOrientation UIToolbar是否应关闭一个像素
我确实向视图中添加了工具栏,如下所示:Iphone 横向模式下的AutoRotateTointerFaceOrientation UIToolbar是否应关闭一个像素,iphone,objective-c,landscape,uitoolbar,autorotate,Iphone,Objective C,Landscape,Uitoolbar,Autorotate,我确实向视图中添加了工具栏,如下所示: 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.my
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];
在界面生成器中,我将视图的“固定”设置为“上边距”和“左边距”。
同样在模拟的度量中,我将状态栏设置为黑色,顶部栏设置为导航栏,底部栏设置为无
这在肖像模式下非常有效。看起来是这样的:
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];
现在,当我旋转到landscapemode时,工具栏的大小被调整,除了按钮之外的所有东西都被关闭了
通过这样的一个像素:
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];
这可能是什么原因造成的?以下代码正在工作:
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];
编辑
这实际上是iOS5模拟器上出现的一个bug。以下代码正在运行:
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];
编辑
这实际上是一个发生在iOS5模拟器上的错误。这确实解决了问题,但带来了另一个问题!现在工具栏保持在44的高度,我不想这样,因为它应该像导航栏一样调整大小。对不起,我猜这就是你要找的。实际上,我想知道它是否来自模拟器。我用iOS5模拟器试过你的代码,发现了你的问题。但是当我尝试使用iOS4或iOS4.3时,没有问题……你完全正确这只是模拟器中的一个bug,它的工作原理就像我在手机上想要的一样。愚蠢的我没有在电话上尝试。谢谢。请编辑您的答案,其他人谁有这个问题,我会标记为正确的答案。这确实解决了问题,但带来了另一个问题!现在工具栏保持在44的高度,我不想这样,因为它应该像导航栏一样调整大小。对不起,我猜这就是你要找的。实际上,我想知道它是否来自模拟器。我用iOS5模拟器试过你的代码,发现了你的问题。但是当我尝试使用iOS4或iOS4.3时,没有问题……你完全正确这只是模拟器中的一个bug,它的工作原理就像我在手机上想要的一样。愚蠢的我没有在电话上尝试。谢谢。请编辑您的答案为其他谁有这个问题,我会标记为正确的答案。