ios - 在 objective-c 中选择文本时,如何防止出现复制按钮?

标签 ios objective-c xcode

我不希望在选择文本时出现“复制/定义”按钮。 我怎样才能在 objective-c 中做到这一点?

更新:我想在 UIWebView 中执行此操作

最佳答案

The easiest way to disable pasteboard operations is to create a subclass of UITextView that overrides the canPerformAction:withSender: method to return NO for actions that you don't want to allow:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(paste:))
        return NO;
    return [super canPerformAction:action withSender:sender];
}

另见 UIResponder

来自这个 question 的答案发布者 rpetrich

关于ios - 在 objective-c 中选择文本时,如何防止出现复制按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30876386/

相关文章:

ios - 为什么我不能在选项卡式应用程序中使用初始化的数组?

objective-c - iOS UITableView : Custom sections using information from a JSON object, 不只是计算它

ios - 如何通过 UIActivityViewController 共享多个 url?

ios - 为什么选择其他分割后iOS分割控件的颜色无法恢复

ios - 如何从 iOS 的共享扩展中的扩展上下文中获取项目?

objective-c - Obj-, 'self'没有设置为 '[(super or self) init...]'的结果时使用的实例变量

ios - 将随机元素添加到数组(swift)

ios - 防止 UIPageViewController 的滑动影响 UISlider

ios - 调试 iOS 应用程序 : crash under Xcode but keep working on iPhone

iphone - 设计一个类似 Flipboard 的 iOS 应用程序需要什么?