Daniyar
Daniyar

Reputation: 3003

IPad navigation controller toolbar position

I have a UIViewController inside of UINavigationViewController. I use navigationController.toolbar for some actions.

Before

There's no problem until the first device rotation. After it toolbar goes off the screen frame.

After

And there's nothing to be done, even another device rotations can't fix this. The problem occurs only on IPad ios v.6. The code is very simple:

- (void)createToolbar{
   UIImage *toolbarBack = [[UIImage imageNamed:@"navbar"] resizableImageWithCapInsets:UIEdgeInsetsMake(2, 2, 2, 2)];
   [self.navigationController.toolbar setBackgroundImage:toolbarBack forToolbarPosition:UIBarPositionBottom barMetrics:UIBarMetricsDefault];
   self.navigationController.toolbar.delegate = self;
   //...
   self.toolbarItems = @[item1, space, item2, space, item3, space, item4];
}

- (void)showToolbar{
   [self.navigationController setToolbarHidden:YES animated:NO];
}

#pragma mark - toolbar delegate methods

- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar{
   return UIBarPositionBottom;
}

UPDATE I found out that before the rotation navigationController.view.height == 1004 and after the rotations it increase by 20 (1024). Is it some statusbar issue?

Upvotes: 2

Views: 934

Answers (1)

Greg
Greg

Reputation: 25459

Set up toolbar delegate to your view controller and implement method:

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
    return UIBarPositionBottom;
}

If you use storyboard you can create constraint between bottom of the screen and your toolbar.

Upvotes: 2

Related Questions