ios5键盘问题

 最近做的ios输入键盘在ios5上面有问题,主要是ios5上面中文键盘,会对出来一块,我原来用的是toolbar和输入键盘不是在一起的,而位置是写死的,这样就造成了ios5上面会遮盖,在网上找了下,解决方法如下,实际上就是获得输入键盘的高度,而不要写死位置,这样也避免以后出问题。

- (void)viewDidLoad

[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHidden:)
name:UIKeyboardWillHideNotification object:nil];
}

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

}

- (void)keyboardWillShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;//得到键盘的高度
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
[super dealloc];
}

你可能感兴趣的:(ios)