레이아웃 구성시
입력부분을 아렛쪽에 구성하였는데
키보드가 나타나면서 가릴때
init 또는 viewdidload 등에서
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown)
name:UIKeyboardWillShowNotification //키보드가 나타날 때
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasDisappear)
name:UIKeyboardWillHideNotification //키보드가 사라질 때
object:nil];
추가
-(void)keyboardWasShown
{
[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationCurveEaseIn
animations:^{
CGRect newframe = self.view.frame;
newframe.origin.y -=150;
[self.view setFrame:newframe];
}
completion:^(BOOL finished){
}];
}
-(void)keyboardWasDisappear
{
[UIView animateWithDuration:0.2f
delay:0.0f
options:UIViewAnimationCurveEaseIn
animations:^{
CGRect newframe = self.view.frame;
newframe.origin.y +=150;
[self.view setFrame:newframe];
}
completion:^(BOOL finished){
}];
}