// 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];
}
本文介绍如何通过UIControl实现UITextView内的可点击区域,并提供了两种方式来切换不同的输入视图,包括如何让系统键盘出现及如何用自定义视图替代默认的键盘输入。
781

被折叠的 条评论
为什么被折叠?



