美文网首页
2019-07-11

2019-07-11

作者: 袁野_508f | 来源:发表于2019-07-12 09:57 被阅读0次

    键盘

    #pragma mark - UITextFieldDelegate

    - (BOOL)textFieldShouldBeginEditing:(UITextField*)textField

    {

        UIWindow * window=[[[UIApplication sharedApplication] delegate] window];

        CGRectframe=[textField convertRect: textField.bounds toView:window];

        intoffset = frame.origin.y- (SCREEN_HEIGHT-260.0);//iPhone键盘高度216,iPad的为352

        if (IS_IPHONE_X) {

            offset = frame.origin.y- (SCREEN_HEIGHT-333.0);

        }

        [UIView beginAnimations:@"ResizeForKeyboard" context:nil];

        [UIView setAnimationDuration:0.5f];

        //将视图的Y坐标向上移动offset个单位,以使下面腾出地方用于软键盘的显示

        if(offset >0)

            self.view.frame=CGRectMake(0.0f, -offset,SCREEN_WIDTH,self.view.frame.size.height);

        [UIView commitAnimations];

        return YES;

    }

    - (BOOL)textFieldShouldReturn:(UITextField*)textField {

        self.view.frame = CGRectMake(0, EldenNav_Sta_Height, SCREEN_WIDTH, self.view.frame.size.height);

        [UIView commitAnimations];

        [textFieldresignFirstResponder];

        return YES;

    }

    相关文章

      网友评论

          本文标题:2019-07-11

          本文链接:https://www.haomeiwen.com/subject/iatrkctx.html