我打电话给方法,
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.name resignFirstResponder];
[self.userName resignFirstResponder];
[self.mailId resignFirstResponder];
[self.password resignFirstResponder];
[self.reTypePassword resignFirstResponder];
}
为了辞职第一个responder.it工作正常而不使用scrollview.but如果我使用scrollview我不能使用此方法。为什么?
答案 0 :(得分:3)
如果需要使用滚动视图,可以添加手势识别器。 试试这个:
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resignFirstResponder:)];
gestureRecognizer.delegate = self;
[scrollView addGestureRecognizer:gestureRecognizer];
-(void) resignFirstResponder:(UITapGestureRecognizer *) gesture
{
[self.name resignFirstResponder];
[self.userName resignFirstResponder];
[self.mailId resignFirstResponder];
[self.password resignFirstResponder];
[self.reTypePassword resignFirstResponder];
}
还有更多选择:见 UIScrollView prevents touchesBegan, touchesMoved, touchesEnded on view controller, UIScrollView touchesBegan