柠檬丶不萌
柠檬丶不萌
  • 发布:2017-02-20 21:32
  • 更新:2017-02-20 21:32
  • 阅读:1208

监听获取键盘高度

分类:Native.js
  • (void)viewDidLoad
    {
    [super viewDidLoad];

    //增加监听,当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(keyboardWillShow:)
    name:UIKeyboardWillShowNotification
    object:nil];

    //增加监听,当键退出时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(keyboardWillHide:)
    name:UIKeyboardWillHideNotification
    object:nil];

}

//当键盘出现或改变时调用

  • (void)keyboardWillShow:(NSNotification )aNotification
    {
    //获取键盘的高度
    NSDictionary
    userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    int height = keyboardRect.size.height;
    }

//当键退出时调用

  • (void)keyboardWillHide:(NSNotification *)aNotification
    {

}

能把这个原生代码 用native.js实现吗?

2017-02-20 21:32 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复