Ios :: toolbar alignment issue

50 views Asked by At

i have added toolbar in the xib file. but it doesn't show up correctly in ios6 simulator. it shows up perfect in ios4 simulator.

below are screenshots.

iphone 6 image

iphone6 image

Iphone4s image

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.

Please help to fix the issue...

1

There are 1 answers

0
Anjali On

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.