views:

170

answers:

3

I have a parent UIView with 2 subviews: a UIButton and a UIScrollView with a UITapGestureRecognizer implemented. The UITapGestureRecognizer is used to zoom in and out the scrollview and the button is used to show/hide some text.

My problem is that once I've used the UIButton, the UITapGestureRecognizer is no longer functioning.

Also, the UITapGestureRecognizer is implemented from within the class for the scrollView, which is necessary to calculate the zoomScale correctly.

I've found a few similar questions, except they were having the opposite problem. Any ideas?

Thanks!

Edit: I just realized that after using the button, if I scroll around or pinch/zoom in the scrollView and then tap, it works again. It just doesn't work immediately after using the button.

Also, here's my code for how the button shows the text view:

- (void)textImageButtonAction:(id)sender{
    if(self.textView.frame.origin.y < 0){
        [UIView beginAnimations:@"HideTabbar" context:nil];
        [UIView setAnimationDuration:.3];
            textView.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, footerStringSize.height +10);
        [UIView commitAnimations];
    }
    else if(self.textView.frame.origin.y == 0) {//If the textView is visible
        [UIView beginAnimations:@"HideTabbar" context:nil];
        [UIView setAnimationDuration:.3];
            textView.frame = CGRectMake(0, -footerStringSize.height -10, self.view.frame.size.width, footerStringSize.height +10);
        [UIView commitAnimations];
    }
 }
+1  A: 

Should you resign first responder after the button has done its duty so that the view that the button is in is no longer in control.

How about adding: bringSubviewtoFront:scrollview

to the end of your UIButton code. The idea here is to make your scrollview the foremost view; which is what I think is happening when you touch the scrollview and thus reactivating the gesture recognizer

Nungster
That what I thought as well. But it doesn't work. I tried adding [textImageButton resignFirstResponder]; at the end of the textImageButtonAction with no effect.
Jonah
Bringing the subview to the front just hides the buttons and does not reactivate the gesturerecognizer. I've also tried calling: [self scrollViewDidScroll:myScrollView]; but that doesn't work either.
Jonah
+1  A: 

Have you tried to call [scrollView becomeFirstResponder]? That should make it work.

jv42
Yes, it didn't make any difference. Thanks for the suggestion though.
Jonah
I had problems like that while using modal views. Is you scroll view presented modally?
jv42
A: 

I finally sought Apple Developer Tech Support for this issue and they looked through my code. The cause of the problem turned out to be conflicting gesture recognizers in different classes. It was a first responder issue, but for some reason, resignFirstResponder and becomeFirstResponder did not have any effect.

I had to restructure the code and how the gesture recognizers were organized to get it to work properly.

Thanks everyone for the help.

Jonah