1

サブクラス化されたUITextView

これがhファイルです

@interface CTextView : UITextView {
}
@end

これがmファイルコードです

#import "CTextView.h"
@implementation CTextView


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

これは、サブクラス化されたUITextviewが使用している最初のUIViewControllerファイルです。

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


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

ただし、UITextViewからすべてをコピー選択することを防ぐことはできません。それでも何かが足りない、または間違っている場合はお知らせください。

手伝ってくれてありがとう。

4

3 に答える 3

2

これを使用して、コピーを無効にします。

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    return NO;
}
于 2012-05-17T14:38:13.417 に答える
1

とった。今それは働いています

これが必要な人のための参照用のコードです

- (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からそれを無効にするためにそれに取り組む必要があります。

于 2012-05-17T14:44:12.400 に答える
0

ユーザーインタラクションを有効に設定しましたか?

于 2012-05-17T13:49:06.540 に答える