OGeek|极客世界-中国程序员成长平台

标题: ios - 禁用双击弹出 UITextView [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:19
标题: ios - 禁用双击弹出 UITextView

双击UITextView 会弹出一个窗口。您可以在下图中看到它。我们如何禁用它?

enter image description here



Best Answer-推荐答案


试试这个:

txtView.selectable = NO;

已编辑: 在你的 View Controller 中覆盖这个来处理,在你有 UITextfield 的地方使用这个代码。

// Hide cut/copy/paste menu


-(BOOL)canPerformActionSEL)action withSenderid)sender {
         UIMenuController *menuController = [UIMenuController sharedMenuController];
         if (menuController) {
            [UIMenuController sharedMenuController].menuVisible = NO;
         }
         return NO;
  }

对于 iOS 7 及更高版本,您需要这样做:

- (BOOL)canPerformActionSEL)action withSenderid)sender {
    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
        [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
    }];
    return [super canPerformAction:action withSender:sender];
}

希望它对你有用。

关于ios - 禁用双击弹出 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27566052/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4