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];

    }

  • 相关阅读:
    HP DL60 Gen9 安装CentOS 6.5
    导出excel的另外一种方法 作者 roc 日期 2006224 10:26:00
    JS获取屏幕大小
    jQuery获取Select选择的Text和 Value(转)
    阿拉伯數字換中文小寫
    html Frame 框架 点击伸缩
    JQuery datepicker 用法
    js 弹出对话框3种方式(摘)
    水晶报表中提示已达到系统管理员配置的最大报表处理作业数限制
    C# 操作word (转)
  • 原文地址:https://www.cnblogs.com/sgdkg/p/2875435.html
Copyright © 2011-2022 走看看