Reputation: 2035
I have an UIView named _containerView and inside this UIView I have a custom UITextView named _codeTextView. When the app is loaded, these views occupies the whole screen, however, when the keyboard appears, I would like the screens to resize.
I have to following method when the keyboard appears:
- (void)keyboardAppears:(NSNotification *)notification
{
_containerView.frame = CGRectMake(0, 0, 320, 216.0f);
_codeTextView.frame = CGRectMake(0, 30, 290, 216.0f);
}
The containerView gets resized properly however, the _codeTextView in it does not resize and I really have no clue why it's not resizing. I've already tried changing various options and it's driving me crazy :(
Could anyone help me?
Thanks in advance!
Upvotes: 2
Views: 1329
Reputation: 4045
I just created a project with the scenario you described. setFrame worked for all views with Autolayout disabled, but not with Autolayout enabled.
Do you have Autolayout enabled for that View Controller? setFrame does not work well with autolayout. You'll have to use constraints to programmatically adjust your views. (answer from: Can I use setFrame and autolayout on the same view?)
You can find some help here: http://nszombie.com/2010/12/08/ConstraintBasedLayout.html
Upvotes: 8