본문 바로가기

블로그/아이폰/iOS

[iOS] 키보드 노티피케이션 활용


-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self registNotification];
}

-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self unregistNotification];
}

-(void) registNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification
object:nil];
}

-(void) unregistNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification object:nil];

[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification object:nil];
}


- (void)keyboardWillShow:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;



}

- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{


}