关闭

键盘设置

88人阅读 评论(0) 收藏 举报
分类:

   

键盘的调用  打开1


[theTextField becomeFirstResponder];

关闭


[theTextField resignFirstResponder];








 在viewdidLoad中添加

    // 键盘的frame发生改变时发出的通知(位置和尺寸)

    //    UIKeyboardWillChangeFrameNotification

    //    UIKeyboardDidChangeFrameNotification

    // 键盘显示时发出的通知

    //    UIKeyboardWillShowNotification

    //    UIKeyboardDidShowNotification

    // 键盘隐藏时发出的通知

    //    UIKeyboardWillHideNotification

    //    UIKeyboardDidHideNotification

    [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(keyboardDidShow:)name:UIKeyboardWillChangeFrameNotificationobject:nil];    

    



//keyBoard已经展示出来

- (void)keyboardDidShow:(NSNotification *)notification

{

//    NSValue* aValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];

//    CGRect keyboardRect = [aValue CGRectValue];

//    CGRect keyboardFrame = [self.view convertRect:keyboardRect fromView:[[UIApplication sharedApplication] keyWindow]];

//    CGFloat keyboardHeight = keyboardFrame.size.height;

//    NSLog(@"##keboardHeight=%.2f",keyboardHeight);

    //lastView最底层的View

    self.lastView.frame = CGRectMake(0, -100,DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT);

//    self.ButtonView.center = CGPointMake(DEF_SCREEN_WIDTH/2, DEF_SCREEN_HEIGHT/2 - 40);

}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:19642次
    • 积分:396
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:50篇
    • 译文:0篇
    • 评论:0条
    文章分类