I keep getting the following error when I dismiss the dictionary that opens from tapping Define on the UIMenuController in a UIWebView on the iPhone:-
Unbalanced calls to begin/end appearance transitions for <_UIFallbackPresentationViewController: 0x10ab9640>.
And after this error, the UIMenuController stops showing up, in any UIWebView.
Any ideas what's going on here?
UPDATE: The error actually shows up when the dictionary view is opening, not when dismissing it.
UPDATE 2: The error is app wide. Anywhere there is selectable text (i.e. webview, textview etc.) I can only use the define dictionary once. This error shows up & then, I have to quit the app & start it again, to use the dictionary.
Finally found an answer for this. When the dictionary gets presented by the system, its window gets focus (see makeKeyAndVisible: in UIWindow), which is great. The problem comes when dismissing where the window holding the dictionary doesn't properly give the main application window back focus.
If you print out the [UIApplication sharedApplication].keyWindow before and after the dictionary gets presented then you'll see how before your application window was keyAndVisible and afterwards it is a different window. For me, I had a separate window for app messages that lived on top of the status bar, and that one was what was keyAndVisible after the dictionary was dismissed.
So all I had to do to fix it was have the following override method in my UIWindow subclass that incorrectly received focus:
- (void) makeKeyWindow {
AppDelegate * appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window makeKeyAndVisible];
}
I'm not sure how this will work for those if you without your own UIWindow that gets focused on, but absolute worst case you could add a dummy UIWindow that would receive focus and add the exact same piece of code from above.
The error message suggests you start a transition but the call to the corresponding end method is missing.
Have you tried doing the transition without animation? (
animated: NO
)Sometimes this behavior appears when using a switch statement and forgetting the
break;
If you are performing a seque, do it in
-viewDidAppear
instead of-viewWillAppear
Hope it helped a bit! :)
来源:https://stackoverflow.com/questions/12106562/uifallbackpresentationviewcontroller