Disable long press menu in text area/input UIWebview

后端 未结 2 1251
别那么骄傲
别那么骄傲 2021-01-20 00:12

This seems to be one of the most frequently discussed topics here but I couldn\'t find a solution which actually works. I\'m posting this question to share a solution which

2条回答
  •  感动是毒
    2021-01-20 00:31

    Also you can hide menu:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuWillBeShown:) name:UIMenuControllerWillShowMenuNotification object:nil];
    
    ...
    
    - (void)menuWillBeShown:(NSNotification *)notification {
        dispatch_async(dispatch_get_main_queue(),^{
            [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
        });
    }
    

    The essential trick here is dispatch_async.

提交回复
热议问题