美文网首页
iOS系统键盘和自定义键盘的切换

iOS系统键盘和自定义键盘的切换

作者: 斌小狼 | 来源:发表于2016-10-21 16:12 被阅读0次

// 1. 给UITextView增加一个可面击的UIControl    UIControl *control = [[UIControl alloc] initWithFrame:_inputView.bounds];    [control addTarget:self];

// 1. 给UITextView添加一个可点击的UIControl

UIControl *control = [[UIControl alloc] initWithFrame:_inputView.bounds];

[control addTarget:self action:@selector(inputViewTapHandle) forControlEvents:UIControlEventTouchUpInside];

[_inputView addSubview:control];

#pragma mark - 从别的inputView切换为系统键盘

//强行调用系统键盘

- (void)inputViewTapHandle{

    MyLog(@"%s", __FUNCTION__);

    [_inputView becomeFirstResponder];

    _inputView.inputView = nil;

    [_inputView reloadInputViews];

}

- (void)addBtnClick

{

[_inputView resignFirstResponder];

MyLog(@"%s", __FUNCTION__);

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150)];

view.backgroundColor = [UIColor grayColor];

_inputView.inputView = view;

[_inputView becomeFirstResponder];

}

- (void)smileBtnClick

{

[_inputView resignFirstResponder];

MyLog(@"%s", __FUNCTION__);

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150)];

view.backgroundColor = [UIColor orangeColor];

_inputView.inputView = view;

[_inputView becomeFirstResponder];

}

相关文章

网友评论

      本文标题:iOS系统键盘和自定义键盘的切换

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