views:

272

answers:

1

I have a UIViewController subclass that is acting as the delegate for a UITextView. I implemented textViewDidBeginEditing to display a 'Done' button to dismiss the text view... all is well... except that when the text view has text and is not in edit mode, if a user holds a finger in the text view causing the text to be zoomed with the magnifying glass, the keyboard appears but textViewDidBeginEditing does not fire.

I have tried to work around this by implementing the UIScrollView delegate methods viewForZoomingInScrollView and scrollViewDidEndZooming but I can't get those to fire for me at all.

I tried playing with the minimumZoomScale and maximumZoomScale properties to disable zooming... to no avail.

At this point I have no idea what to try next or if my failure catching the UIScrollView delegate methods is related to my main issue. I'm uncertain what code I could post that would be of value... the textViewDidBeginEditing method is very minimal and works fine in normal circumstances. The UITextView delegate assignment is made with a connection in Interface Builder to the controller (File Owner).

+1  A: 

A workaround might be to register to the keyboard notifications. Once you do will know exactly when the keyboard is displayed.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationShow:) name:UIKeyboardWillShowNotification object:nil];  

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationHide:) name:UIKeyboardWillHideNotification object:nil];
Ron Srebro
thank you for the suggestion... my problem with this workaround is that I have several text views in the app and I'm not sure how I'd identify which one caused the notification.
This is working for me now after adding a check (self.view.window != NULL) to make sure the controller's view is being displayed.