简体   繁体   中英

[UIMenuController sharedMenuController].menuVisible says YES but menu is not visible?

In my code I use this test

if ([UIMenuController sharedMenuController].menuVisible) {

However, that doesn't always work. In my case, if the user double-taps a word in the UITextView, the menu keeps reporting visible = YES ever after.

I tried adding this test:

    UIMenuController * c = [UIMenuController sharedMenuController];
    CGRect test4 = c.menuFrame;
    if (test4.size.width != 0 || test4.size.height != 0) {
        return;    
    } else {
        NSLog(@"Shared menu controller claims to be visible but isn't");
    }

This works, but not all the time.

Any ideas?

It turns out that the reason was that I had pushed another window on top and not removed it. Invisibly to me, the menu was now presented in that window, and so was technically visible. In the invisible window.

Anyway, remember to keep track of your windows folks! That's all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM