当前位置: 首页 > 工具软件 > iOS7 Menu > 使用案例 >

iOS16 UIMenuController 点击无效

松茂实
2023-12-01

直接上结果

UIMenuController * menu = [UIMenuController sharedMenuController];

[self.view becomeFirstResponder];

UIMenuItem * item1 = [[UIMenuItem alloc]initWithTitle:@"复制1" action:@selector(copyText:)];

menu.menuItems = @[item1];

[menu setTargetRect:weak_label.bounds inView:weak_label];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

[menu setMenuVisible:YES animated:YES];

显示的时候添加个延迟!!真是大坑

 类似资料: