Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:47:58+00:00 2026-06-04T07:47:58+00:00

I have a single view application that only contains a web view and a

  • 0

I have a single view application that only contains a web view and a text field which acts like an address bar. After selecting part of a web page, I want to push a button to copy it (all of the selection including text and pictures) and automatically paste it into another view.
I can add a button to the edit menu (although I don’t know how to remove the copy and paste buttons), but I don’t know how to get the selection.

I have tried to use gesture recognizers to do this but I cannot find a way to get the selection. I set my view controller as a UIWebViewDelegate and an UIGestureRecognizerDelegate and tried to implement touchesBegan, touchesMoved and touchesEnded, but they don’t get called when starting selection. Do you know an example with something like this or at least point me in the good direction? Thank you!

UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Copy String" action:@selector(stringFromSelection:)];
UIMenuController *menuController = [UIMenuController sharedMenuController];
menuController.menuItems = [NSArray arrayWithObject:menuItem];

-(void)stringFromSelection:(id)sender
{
NSString *selectionString = [browserView stringByEvaluatingJavaScriptFromString:@"window.getSelection()"];    //browserView is UIWebView class
NSLog(@"selected string = %@",selectionString);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:47:59+00:00Added an answer on June 4, 2026 at 7:47 am

    the solution to get the selected text and copy it to add .ToString() to your function .. finally it will be :

    -(void)stringFromSelection:(id)sender
    {
    NSString *selectionString = [browserView stringByEvaluatingJavaScriptFromString:@"window.getSelection().ToString()"];
    NSLog(@"selected string = %@",selectionString);
    }
    

    am not sure if this will work with images also .. test it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to implement Single Page Web Application that would have sensitive data,
I have a view that contains a UITableView and a UILabel which works perfectly
I need to have various text view on a single line. And I want
I have a View based application for iPhone/iPod that plays audio, having a VU
In my application, I've got several ViewModels that have a single service (repository, DAO,
I'm in the technologies selection phase of a small, single-page web application that will
I have picker controls on a single view with two outlets for each. When
I have a single annotation on a map view. I can select it programmaticly,
We have a single SVN repository with multiple related projects. Like so... \repo \Project1
I have a single AMQ queue that receives simple messages with string body. Consider

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.