//增加監(jiān)聽,當(dāng)鍵盤出現(xiàn)或改變時收出消息
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//增加監(jiān)聽,當(dāng)鍵盤退出時收出消息
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
____________________________________________________________________
//當(dāng)鍵盤出現(xiàn)或改變時調(diào)用
- (void)keyboardWillShow:(NSNotification*)aNotification
{
//獲取鍵盤的高度
NSDictionary*userInfo = [aNotificationuserInfo];
NSValue*aValue = [userInfoobjectForKey:UIKeyboardFrameEndUserInfoKey];
CGRectkeyboardRect = [aValueCGRectValue];
intheight = keyboardRect.size.height;
if(self.ps.sureNumTF.isEditing) {
self.ps.frame=CGRectMake(0, -height, [[UIScreenmainScreen]bounds].size.width, [[UIScreenmainScreen]bounds].size.height);
}
}
//當(dāng)鍵退出時調(diào)用
- (void)keyboardWillHide:(NSNotification*)aNotification
{
self.ps.frame=CGRectMake(0,0, [[UIScreenmainScreen]bounds].size.width, [[UIScreenmainScreen]bounds].size.height);
}