iOS-OC初级首页投稿(暂停使用,暂停投稿)

-[UIKBBlurredKeyView candidateLi

2016-07-28  本文已影响269人  小弱鸡

Scrollview上的输入框无法实现键盘回收,于是引入如下代码来解决这个问题

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    [super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    [super touchesEnded:touches withEvent:event];
}

虽然解决了键盘回收,但是在做手写输入时候,会出现闪退的情况,并报错

-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x17

(其他页面做某些操作的时候也会出现问题)
显然出现这个上述方法是不可行,注销该方法。经过查找资料我寻找到一个新的方式来解决这个问题
贴代码

    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchScrollView)];
    [recognizer setNumberOfTapsRequired:1];
    [recognizer setNumberOfTouchesRequired:1];
    [BKScrollview addGestureRecognizer:recognizer];


- (void)touchScrollView{
    UITextField * name = [topImageView viewWithTag:1];
    UITextField * phoneNum = [topImageView viewWithTag:2];
    UITextField * adress = [topImageView viewWithTag:4];
    [name endEditing:YES];
    [name resignFirstResponder];
    [phoneNum resignFirstResponder];
    [adress resignFirstResponder];
}
上一篇下一篇

猜你喜欢

热点阅读