UIToolbar goes under status bar in iOS7
Asked Answered
P

3

6

I have a UIView and I have a UIToolbar and UIWebView. I want to show toolbar at top of UIView and after that the rest of page covered with webView. But toolbar goes under status bar like this enter image description here

How can I correct it in iOS7.

Paedogenesis answered 7/12, 2013 at 13:45 Comment(1)
are you using xib or prog?Belvabelvedere
N
13

1) Set the toolbar Y position to 20 (in the interface builder or in the code)

2) Set the toolbar delegate

3) In your toolbar delegate implement:

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

enter image description here

Ninety answered 22/1, 2014 at 11:38 Comment(0)
L
6

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

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
    return UIBarPositionTopAttached;
}
Lustrate answered 7/12, 2013 at 14:5 Comment(2)
Sometimes you still have to move your toolbar 20pt below.Lustrate
You saved my day! Don't forget to set toolbar.delegate = self;Marivaux
M
1

The only correct solution in 2k17 is to attach your toolbar/navigationBar to leading/trailing of your superview, top to topLayoutGuideBottom and to implement positionForBar:. This will produce correct result on all devices.

Marcelmarcela answered 20/9, 2017 at 10:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.