<i id='0nIyG'><tr id='0nIyG'><dt id='0nIyG'><q id='0nIyG'><span id='0nIyG'><b id='0nIyG'><form id='0nIyG'><ins id='0nIyG'></ins><ul id='0nIyG'></ul><sub id='0nIyG'></sub></form><legend id='0nIyG'></legend><bdo id='0nIyG'><pre id='0nIyG'><center id='0nIyG'></center></pre></bdo></b><th id='0nIyG'></th></span></q></dt></tr></i><div id='0nIyG'><tfoot id='0nIyG'></tfoot><dl id='0nIyG'><fieldset id='0nIyG'></fieldset></dl></div>
    <bdo id='0nIyG'></bdo><ul id='0nIyG'></ul>
  • <legend id='0nIyG'><style id='0nIyG'><dir id='0nIyG'><q id='0nIyG'></q></dir></style></legend>

    1. <small id='0nIyG'></small><noframes id='0nIyG'>

    2. <tfoot id='0nIyG'></tfoot>

        如何从 UIWebView 获取选择文本?

        时间:2023-10-22
        1. <i id='35KLI'><tr id='35KLI'><dt id='35KLI'><q id='35KLI'><span id='35KLI'><b id='35KLI'><form id='35KLI'><ins id='35KLI'></ins><ul id='35KLI'></ul><sub id='35KLI'></sub></form><legend id='35KLI'></legend><bdo id='35KLI'><pre id='35KLI'><center id='35KLI'></center></pre></bdo></b><th id='35KLI'></th></span></q></dt></tr></i><div id='35KLI'><tfoot id='35KLI'></tfoot><dl id='35KLI'><fieldset id='35KLI'></fieldset></dl></div>
        2. <legend id='35KLI'><style id='35KLI'><dir id='35KLI'><q id='35KLI'></q></dir></style></legend>

          • <bdo id='35KLI'></bdo><ul id='35KLI'></ul>

                <tfoot id='35KLI'></tfoot>

                  <tbody id='35KLI'></tbody>

                <small id='35KLI'></small><noframes id='35KLI'>

                  本文介绍了如何从 UIWebView 获取选择文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  ,大家好.

                  我正在开发我的应用程序,该应用程序具有从网站发布文章的功能.

                  I'm developing my app which has a feature to post article from website.

                  这是带有 UIMenuController 的 UIWebview 的图片.

                  This is a picture of UIWebview with UIMenuController.



                  用户点击按钮时可以获得事件.但我找不到获取用户选择的文本的方法.



                  It was possible to get event when user tap the button. but I can't find the way to get the text the user selected.

                  在 UITextView 的情况下,它有 'selectedRange' 属性,因此很容易获取选择文本.

                  In UITextView case, it has 'selectedRange' property, so it is easy to get selection text.

                  UIMenuItem *facebookMenuItem = [[UIMenuItem alloc] initWithTitle:@"Facebook" action:@selector(facebookMenuItemTapped:)];
                  UIMenuItem *twitterMenuItem = [[UIMenuItem alloc] initWithTitle:@"Twitter" action:@selector(twitterMenuItemTapped:)];
                  
                  [UIMenuController sharedMenuController].menuItems = [NSArray arrayWithObjects: facebookMenuItem, twitterMenuItem, nil];
                  
                  [twitterMenuItem release];
                  [facebookMenuItem release];
                  

                  我想在 UIWebView 上获取选择文本.有人有想法或提示吗?

                  I would like to get the selection text on UIWebView. Does anybody have an idea or hint?

                  谢谢.

                  推荐答案

                  或者,如果您不想弄乱 Javascript,您可以将所选内容复制到粘贴板,然后通过运行检索它:

                  Or if you dont want to mess with Javascript you can just copy the selection to the pasteboard and then retrieve it by running:

                      [[UIApplication sharedApplication] sendAction:@selector(copy:) to:nil from:self forEvent:nil];
                      NSString *text =  [UIPasteboard generalPasteboard].string;
                  

                  这篇关于如何从 UIWebView 获取选择文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 UIWebView 忽略无效的服务器证书 下一篇:过渡到 iOS 7:在 iPad 上查看的 jQuery/iPhone Web 应用程序的正确视口设置

                  相关文章

                    <bdo id='F0QTu'></bdo><ul id='F0QTu'></ul>

                  <small id='F0QTu'></small><noframes id='F0QTu'>

                    <i id='F0QTu'><tr id='F0QTu'><dt id='F0QTu'><q id='F0QTu'><span id='F0QTu'><b id='F0QTu'><form id='F0QTu'><ins id='F0QTu'></ins><ul id='F0QTu'></ul><sub id='F0QTu'></sub></form><legend id='F0QTu'></legend><bdo id='F0QTu'><pre id='F0QTu'><center id='F0QTu'></center></pre></bdo></b><th id='F0QTu'></th></span></q></dt></tr></i><div id='F0QTu'><tfoot id='F0QTu'></tfoot><dl id='F0QTu'><fieldset id='F0QTu'></fieldset></dl></div>
                    <legend id='F0QTu'><style id='F0QTu'><dir id='F0QTu'><q id='F0QTu'></q></dir></style></legend>

                    1. <tfoot id='F0QTu'></tfoot>