I feel like an idiot, because i fight with something, that should be very straighforward, but there is a hidden sabouteur in my Xcode somewhere.
The UI is built in StoryBoard.
I have a modal view, that contains an upper UINavigationBar and a UIScrollView…inside a scrollview are some textfields.
Now I understand that when I start to edit a text in textfield, a keyboard pops out. Thats ok. I am tracking that moment via NotificationCenter.
[notificationCenter addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
I am calling a selector when that happens
-(void)keyboardDidShow:(NSNotification *)notification
{
... code changing the frame
}
Of course, I need to resize the scrollview to make room for the keyboard, but AS SOON AS I attach a newly created CGRect “frame” value of scrollview’s frame, the scrollview does NOT resize according to my wishes, but instead takes a size of a vieconntroller’s view minus the statusbar’s 44 pixels..
I lost a few hours on this already and it drives me nuts. Can you help?
First: why do you need to change the frame of the scrollview? The keyboard just appears above everything anyway. Perhaps a more convenient way to catch the editing BTW is the
UITextFieldDelegateprotocol, but I guess your way is fine too.Second: if you want to modify the view that is the view controller’s
viewproperty, you cannot change the frame. It is the full screen (minus status bar, minus nav bar if any) by default. If you want to dynamically resize a view it has to be a subview ofself.view.