What I had done in my xib file is that, Initially I had an uiImageView and over that I had an UIScrollView on which i had put so many other controls. Earlier I was not having scroll view so my touchesBegan event was working properly but now after putting UIScrollView its not responding. I am new in iOS so please tell me what to do?? What I want to do is to hide my keyboard which appears for my UITextView, whenever I touch anywhere on screen. So please help me out... the code of my touchesBegan method is:
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if ([self.txtLoginId isFirstResponder] && [touch view] != self.txtLoginId)
{
[self.txtLoginId resignFirstResponder];
}
if ([self.txtPassword isFirstResponder] && [touch view] != self.txtPassword)
{
[self.txtPassword resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
Probably, your
scrollView
has its propertyuserInteractionEnabled
set toYES
. In this case, thescrollView
receives the touches, and they will not be forwarded to your methodtouchesBegan:withEvent:
.Simply try to set this property to
NO
. This can be done in storyboard in the view section of thescrollView
, or programmatically.