0

こんにちは~一つ質問があります。^^

UIWebView (または UITextView) で「選択したテキスト」を取得するにはどうすればよいですか?

コピー/貼り付けのポップアップ ビューを使用せずに、「選択したテキスト」をコピーしたいと思います。

1)私は削除しました...コピー/貼り付けビュー。(成功でした~)

UIMenuController *theMenu = [UIMenuController sharedMenuController];
[theMenu setMenuVisible:NO];
[theMenu update];

2.「選択したテキスト」を強制コピー(失敗)

copyController.h -------------------------

@interface copyController : UIViewController <UIWebViewDelegate>
{
     UIWebView *WebView;
}

copyController.m ------------------------

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



    // ----------> here !!!!!
    // I'd like to forced copy "selected text" without copy/paste popup-view

   // ** How can i get selected text ???**


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



- (void)copy:(id)sender
{
     UIPasteboard *board = [UIPasteboard generalPasteboard];
     NSLog(@"SENDER : copied : %@",board.string);
}

canPerformAction でテキストをコピーするにはどうすればよいですか。?

「選択したテキスト」をコピーしたいのは、色やフォントを変更してテキストを装飾するためです。

thxあなた〜

4

1 に答える 1

2

文字列をペーストボードに入れるには、次を使用します

[UIPasteboard generalPasteboard].string = @"some text";

選択したテキストを WebView から取得するには、適切な Javascript-stringByEvaluatingJavaScriptFromString:を使用します。

于 2010-02-21T10:53:08.583 に答える