zoukankan      html  css  js  c++  java
  • 键盘盖住输入框问题,包含中英文切换

    只是修改了官方的demo

    - (void)viewDidLoad

    {

        [superviewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

        

        

        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillShow:)  name:UIKeyboardWillShowNotificationobject:nil];

        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotificationobject:nil]; 

        inputview=[[UITextViewalloc] initWithFrame:CGRectMake(123,750, 111,44)];

        [inputviewsetBackgroundColor:[UIColorredColor]];

        [self.view addSubview:inputview];

    }

    - (void)didReceiveMemoryWarning

    {

        [superdidReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

        

    }

    - (BOOL)textViewShouldBeginEditing:(UITextView *)aTextView {

        

        if (inputview.inputAccessoryView == nil) {

            [[NSBundlemainBundle] loadNibNamed:@"AccessoryView"owner:selfoptions:nil];

        }

        

        returnYES;

    }

    - (BOOL)textViewShouldEndEditing:(UITextView *)aTextView {

        [aTextView resignFirstResponder];

        returnYES;

    }

    #pragma mark -

    #pragma mark Responding to keyboard events

    - (void)keyboardWillShow:(NSNotification *)notification {    

        NSDictionary *userInfo = [notification userInfo]; 

        NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

        CGRect keyboardRect = [aValue CGRectValue];

        NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];

        NSTimeInterval animationDuration;

        [animationDurationValue getValue:&animationDuration];

        [UIViewbeginAnimations:nilcontext:NULL];

        [UIView setAnimationDuration:animationDuration];    

        inputview.frame=CGRectMake(123,keyboardRect.origin.y-64, 111,44);

        [UIViewcommitAnimations];

    }

    - (void)keyboardWillHide:(NSNotification *)notification {

        

        NSDictionary* userInfo = [notification userInfo];

        NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];

        NSTimeInterval animationDuration;

        [animationDurationValue getValue:&animationDuration];    

        [UIViewbeginAnimations:nilcontext:NULL];

        [UIView setAnimationDuration:animationDuration];    

        inputview.frame = CGRectMake(123,750, 111,44);    

        [UIViewcommitAnimations];

    }

  • 相关阅读:
    sql的ROWCOUNT的说明。
    引用: 把new、virtual、override说透
    我要在左边的FRAME1里调用右边的FRAME2的JAVASCRIPT函数
    webconfig设置用户控件配置。
    2个Frame用ID标记没用, 用NAME标记有用。 查询BAIDU,如下。
    HttpWebRequest加载证书请求远端https服务器时 : 基础连接已经关闭: 无法与远程服务器建立信任关系
    SELECT 与 SET 对变量赋值的区别(存储过程)
    Ajax小示例
    My97Date 有一个功能强大的时间控件
    Tomcat6.0 管理界面的配置
  • 原文地址:https://www.cnblogs.com/sgdkg/p/2875435.html
Copyright © 2011-2022 走看看