When the focus falls on the input box, the keyboard will appear, this time will block part of the screen (UIView or UIControl),
So how to achieve when the keyboard appears, the effect of the current screen and the screen automatically move can drag
A detailed description of a little brother iphone developers do not understand, please know that heroes ah
Reply:
Use the scroll view, it is very easy to achieve
Reply:
You need the following two protocol
prior UITextFieldDelegateFor example, there is a UITextField * userTextField
After creating the delegate
set userTextField
userTextField.delegate = self;
/ / Start editing, keyboard open, subviewMoveUp () needs to implement change subview position
- (BOOL) textFieldShouldBeginEditing: (UITextField *) textField {
[Self subviewMoveUp];
return YES;
}
/ / Edit end, the keyboard closed, subviewRestore () need to achieve recovery subview position
- (BOOL) textFieldShouldReturn: (UITextField *) textField {
[UserTextField resignFirstResponder];
[Self subviewRestore];
return YES;
}
- (Void) subviewMoveUp {
userTextField.frame = CGRectMake (....);
}
- (Void) subviewRestore {
userTextField.frame = CGRectMake (....);
}
However, the above is without rolling up and down the screen. If you want to roll, you need to use UIScrollView, the userTextField into UIScrollView. The specific needs of specific solutions, using UIScrollView UIScrollView that allows frame change, you can also change the UIScrollView's content offset achieve their goals.
No comments:
Post a Comment