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