-(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
// NSLog(@"canPerformAction");
// NSLog(@"%@", sender);
UIMenuController *menuController = [UIMenuController sharedMenuController];
if(menuController) {
[UIMenuController sharedMenuController].menuVisible = NO;
}
if(@available(iOS13.0, *)) {
[menuController hideMenu];
}else{
[menuController setMenuVisible:NO];
// Fallback on earlier versions
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menushow) name:@"UIMenuControllerDidShowMenuNotification" object:nil];
return NO;
}
- (void) menushow {
UIMenuController *menuController = [UIMenuController sharedMenuController];
if(menuController) {
[[UIMenuController sharedMenuController] setMenuVisible:NO];
}
}
我的项目中所有ViewController都继承自BasicViewController,所以只需要在BasicViewController中添加方法即可
网络查询的方法中没有通知事件的监听,但在实际使用中不咋好用,调试后发现可以在通知事件中修改,通知事件名称来自UIMenuController点进去那里
参考文章://www.greatytc.com/p/274428ed7a2c