0

I've got a UIViewController with UITextView in its view. When user selects text, there's Define system menu item that uses UIReferenceLibraryViewController to define the word. The problem is that the word stays selected after the dictionary is dismissed. I'd prefer it to be deselected (like it's done in iBooks).

I've tried to deselect the word using UIMenuControllerDidHideMenuNotification:

[[NSNotificationCenter defaultCenter] addObserverForName:UIMenuControllerDidHideMenuNotification object:nil queue:nil usingBlock:^(NSNotification *notification) {
    [textView setSelectedRange:NSMakeRange(0, 0)];
}];

This deselects the word but also freezes my UIViewController with the following message:

2012-12-20 19:18:45.553 Pilcrow[7018:c07] Warning: Attempt to dismiss from view controller <_UIFallbackPresentationViewController: 0x75b8300> while a presentation or dismiss is in progress!
2012-12-20 19:18:45.963 Pilcrow[7018:c07] Unbalanced calls to begin/end appearance transitions for <_UIFallbackPresentationViewController: 0x75b8300>.

Any ideas?

Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118

1 Answers1

0

The dismissal probably takes around 0.25-0.33 seconds. So how about doing a performSelectorAfterDelay or dispatch-after after this duration?

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
  • Might be, but it could still be before the end of he animation block or run loop. Also there are cases when the didHide fires too early. – Cocoanetics Dec 22 '12 at 13:15