在UITextView中隐藏UIMenuController [英] Hide UIMenuController in UITextView

查看:384
本文介绍了在UITextView中隐藏UIMenuController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

子类化的UITextView

Subclassed UITextView

这是h文件

@interface CTextView : UITextView {
}
@end

这是m个文件代码

#import "CTextView.h"
@implementation CTextView


- (BOOL)canBecameFirstResponder {
return NO;
}
@end

这是第一个使用子类UITextview的UIViewController文件

Here is first UIViewController file in which subclassed UITextview is using

#import "First.h"
#import "CTextView.h"


textView = [[[CTextView alloc] initWithFrame:CGRectMake(0, 0, 320, 410)]autorelease];
[self.view addSubview:textView];

但是仍然不能阻止复制,请从UITextView中全选.请让我知道我是否仍然缺少任何东西或做错事.

But still not able to prevent copy select all from UITextView. Please let me know if i am still missing anything or doing wrong.

感谢您的帮助.

推荐答案

知道了.现在可以了

以下是任何需要参考的代码

Here is the code for reference for anyone need it

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

{    
[UIMenuController sharedMenuController].menuVisible = NO; //do not display the menu
if (action == @selector(copy:))
{

    return NO;  

}

else  if (action == @selector(selectAll:))
{
    return NO; 

}

[self resignFirstResponder];                      //do not allow the user to selected anything
return NO;

return [super canPerformAction:action withSender:sender];
}

现在唯一的问题是缩放.现在,我必须对此进行操作以从UITextView禁用它.

Now only problem having is Zooming. Now i have to work on that to disable it from UITextView.

这篇关于在UITextView中隐藏UIMenuController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆