【问题标题】:How to disable copy,paste options in UITextView and enable it again iPhone app?如何禁用 UITextView 中的复制、粘贴选项并再次启用 iPhone 应用程序?
【发布时间】:2012-10-20 15:44:23
【问题描述】:

我正在使用基于 UITextView 的 iPhone 应用程序。在我的一个屏幕中,当用户点击屏幕时,我有 3 个 UITextView 显示带有自定义菜单项的 UIMenuController。 In this scenario UITextView is in Active means UITextView is becomResponder. So when i show UIMenuItem taping the screen UITextView UIMenuController showing with "Paste" option.

我想在用户触摸屏幕时从 UITextView 禁用 UIMenuController 项。 Could you please anyone tell me how to disable UITextView with showing keypad and disable UIMenuController.?提前致谢。

【问题讨论】:

    标签: iphone uitextview uimenucontroller disabled-control


    【解决方案1】:

    你可以这样编码:

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

    否则你可以写:

    - (BOOL)canBecomeFirstResponder {
        return NO;
    }
    

    使您的文本文件不可编辑。希望它对你有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-01
      • 2018-04-06
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      相关资源
      最近更新 更多