简体   繁体   中英

Can't resize the height of uiView proportional to keyboard

When I click on textfield, execute this method keyboardDidShow and when I started to typing, the view will be go down. What is the reason for this ? Here is my code,

else if (textField.tag==2) {

    [self.viewUi setFrame:CGRectMake(0,-110,320,460)];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
}
return YES;

}

- (void)keyboardDidShow:(NSNotification *)notification
{
    // Assign new frame to your view
    [self.viewUi setFrame:CGRectMake(0,-110,320,460)];
}

Alwin, this particular post might help you in getting this done

How to make a UITextField move up when keyboard is present?

Or trying adding the NSNotification observer at the time of loading of View Controller as in viewDidLoad .

 - (void)keyboardDidShow:(NSNotification *)notification
    {
        // Assign new frame to your view
        [self.viewUi setFrame:CGRectMake(0,-110,320,460)];
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM