Reputation: 31323
I have a UIViewController
in a Storyboard app.
The Navigation bar is automatically added when a segue is set and I've added a UIToolBar
from the IB to the bottom.
At runtime a UIScrollView
is added to the view controller as the view. The problem that caused was it overlaps the UIToolBar
which was added before. So I added the following line and pulled back the tool bar to the front.
self.mailOptionsToolbar.layer.zPosition = 1;
Now it appears fine but there's still a small issue. When I click on the tool bar button item in the UIToolBar
, they just don't work. Say, in the scroll view if there's UITextbox placed right underneath any of those buttons, when I click them it pops up the keyboard! Its like the click is falling through the UIToolBar
to the UITextField below. How can I stop this from happening?
I was think of another way too. That is resizing the UIScrollBar
to fit only the white spaced area so that it won't cover up the UIToolBar
in the first place thus not spawning this clicking issue. But I don't know how to make the UIScrollView
which is added at runtime to be fit only within the white area.
Suggestions to both of these will be appreciated.
Thank you.
Upvotes: 0
Views: 263
Reputation: 9101
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
// 20.0f is for status bar height and 44.0f is for navigation bar
CGFloat scrollViewHeight = screenHeight - 20.0f - 44.0f - self.mailOptionsToolbar.frame.size.height;
CGRect frame = [CGRectMake(0, 0, 320.0f, scrollViewHeight)];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
Upvotes: 1