Scrollview上的輸入框無法實(shí)現(xiàn)鍵盤回收耘纱,于是引入如下代碼來解決這個(gè)問題
- (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];
}
雖然解決了鍵盤回收废登,但是在做手寫輸入時(shí)候橘原,會(huì)出現(xiàn)閃退的情況擎宝,并報(bào)錯(cuò)
-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x17
(其他頁面做某些操作的時(shí)候也會(huì)出現(xiàn)問題)
顯然出現(xiàn)這個(gè)上述方法是不可行郁妈,注銷該方法。經(jīng)過查找資料我尋找到一個(gè)新的方式來解決這個(gè)問題
貼代碼
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];
}