简体   繁体   English

iOS ::工具栏对齐问题

[英]Ios :: toolbar alignment issue

i have added toolbar in the xib file. 我在xib文件中添加了工具栏。 but it doesn't show up correctly in ios6 simulator. 但在ios6模拟器中无法正确显示。 it shows up perfect in ios4 simulator. 它在ios4模拟器中显示完美。

below are screenshots. 以下是屏幕截图。

iphone 6 image iPhone 6图片

iphone6图片

Iphone4s image Iphone4s图片

iphone 4s iamge

Please look at slide left to delete toolbar in the images, it is fine in iPhone 4s but it comes in between in iPhone 6 simulator. 请向左滑动以删除图像中的工具栏,这在iPhone 4s中很好,但在iPhone 6模拟器中介于两者之间。

Please help to fix the issue... 请帮助解决问题...

Below piece of code fixed my issue for all the simulators. 下面的代码修复了所有模拟器的问题。

//Caclulate the height of the toolbar
CGFloat toolbarHeight = [toolbar frame].size.height;

//Get the bounds of the parent view
CGRect rootViewBounds = [UIScreen mainScreen].bounds;

//Get the height of the parent view.
CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);

//Get the width of the parent view,
CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);

//Create a rectangle for the toolbar
CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
self.toolbar.frame = rectArea;

i have put above code in viewWillAppear method. 我把上面的代码放在viewWillAppear方法中。

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

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