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 7839877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:34:50+00:00 2026-06-02T15:34:50+00:00

i am doing a reader application in IPAD ,the book data is stored in

  • 0

i am doing a reader application in IPAD ,the book data is stored in Sqlite DB,i render this content of DB in a view through core text…the formate of my text is like this e.g.:1 haii this is iPhone. 2 this is iPad. 3 this is mac. etc etc..i just want to get touch events while touching the text.for example if i tap the first sentence,,the fist sentence only must be selected with any color,and trigger a popup(subview or alert view or action sheet)like the image belowenter image description here

i am having this code to make the text to shown in a view

NSMutableString *combined = [NSMutableString string];

    for(NSUInteger idx = 0; idx < [delegatee.allSelectedVerseEnglish count]; idx++) {
        [combined appendFormat:@"  %d %@", 
         idx + 1, 
         [delegatee.allSelectedVerseEnglish objectAtIndex:idx]];

    }

    self.multiPageView.text =combined;

combined is the string contains verses oif the bible of the selected chapter,so when i click the first verse it need to be selected like the image below and pops up a subview or alert view like the image below,and by selection that verse must be stored in somewhere or copy to clipboard.multiPageView is the view that render the core text .i want just like in olive tree bible application or ibook.

i am not using the web view,due to some limitation in the web view..is there any idea how to do this..,please help me.
Thanks in advance.
EDIT:

- (void)textViewDidEndEditing:(UITextView *)textView
{

    mainpopupview.frame =CGRectMake(0, 0, 768, 1004)    ;
    [self.view addSubview:mainpopupview];

    NSRange selectedRange = [textView selectedRange];
    NSString *backString = [maintextview.text substringToIndex:selectedRange.location];
    NSRange backRange = [backString rangeOfString:@"." options:NSBackwardsSearch];
    NSRange backRangee = [backString rangeOfString:@"." options:NSBackwardsSearch];
    int  myRangeLenght = backRangee.location - backRange.location;
    NSRange myStringRange = NSMakeRange (backRange.location, myRangeLenght);
    NSString *forwardString  = [maintextview.text substringFromIndex:backRange.location];
    NSLog(@"%@",[[forwardString componentsSeparatedByString:@"."] objectAtIndex:1]);
    NSLog (@"%@",  [maintextview.text substringWithRange:myStringRange]);

    NSString * myStringTxt = [[forwardString componentsSeparatedByString:@"."] objectAtIndex:1];
    NSLog(@"1 %@", myStringTxt);

      //  maintextview.textColor = [UIColor yellowColor];

    NSRange myStringRangee = [maintextview.text rangeOfString:myStringTxt];
    [maintextview select:self];
    maintextview.selectedRange = myStringRangee;
    }

myStringTxt contains the correct verse(menz text between .to .but i want to elect this text.

  • 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-02T15:34:51+00:00Added an answer on June 2, 2026 at 3:34 pm

    I think you can wire up UITextview’s UIControlEventEditingChanged to some method. So when ever the user selects something that method would be called. Inside the method you can obtain the selected text using,

    NSRange range = [txtView selectedRange];
    NSString *str = [txtView.text substringWithRange:range];
    

    From the selected string you can perform the actions you like.

    If your text view is editable you can get,

    NSLog(@"%d",range.location);
    

    Once you know the location you can create a range and select string. This and this has relevant info.

    //Here is the complete sample code.

      {
            sampleTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, 60, 300)];
            sampleTextView.text = @"This is sample text to find text under touch. I am not going to use any private api.How am i supposed to do?.Let me see.";
            sampleTextView.editable = YES;
            sampleTextView.delegate = (id)self;
            [self.view addSubview:sampleTextView];
        }
    - (void)textViewDidBeginEditing:(UITextView *)textView
    {
    
        [NSTimer scheduledTimerWithTimeInterval:0.001 target:sampleTextView   selector:@selector(resignFirstResponder) userInfo:nil repeats:NO];
    }
    
    - (void)textViewDidEndEditing:(UITextView *)textView
    {
        NSRange selectedRange = [textView selectedRange];
        NSString *backString = [sampleTextView.text substringToIndex:selectedRange.location];
        NSRange backRange = [backString rangeOfString:@" " options:NSBackwardsSearch];
        NSString *forwardString  = [sampleTextView.text substringFromIndex:backRange.location];
        NSLog(@"%@",[[forwardString componentsSeparatedByString:@" "] objectAtIndex:1]);
    }
    

    EDIT :

    I have updated the code based on your requirement. Please find it below,

    UITextView *textview;
    BOOL toggle;
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        textview = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
        textview.delegate = (id)self;
        textview.inputView = [[UIView alloc] init];
        textview.text = @"Let's hope the text selection works programmatically!";
        [self.view addSubview:textview];
    }
    
    - (void)textViewDidChangeSelection:(UITextView *)textView
    {    
        NSRange selectedRange = [textView selectedRange];
        NSString *backString = [textView.text substringToIndex:selectedRange.location];
        NSRange backRange = [backString rangeOfString:@" " options:NSBackwardsSearch];
        NSString *forwardString  = [textView.text substringFromIndex:backRange.location];
    
        NSLog(@"%@",[[forwardString componentsSeparatedByString:@" "] objectAtIndex:1]);
    
        NSRange ran = [textView.text rangeOfString:[[forwardString componentsSeparatedByString:@" "] objectAtIndex:1]];
    
        if (!toggle)
        {
            [self performSelector:@selector(selectText:) withObject:[NSValue valueWithRange:ran] afterDelay:0.001];
        }
        else
        {
            toggle = !toggle;
        }
    }
    
    -(void)selectText:(NSValue *)sender
    {
        toggle = !toggle;
    
        textview.selectedRange = [sender rangeValue];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a reader application which can send text to Facebook. But I
I am doing a reader application,which can sync text to googledoc,i got the working
I want to use an access card reader with PHP. I am doing this
Ha ii ,i am doing a reader application which have chapters in it,i have
Ha ii everybody ,i am doing a reader application in iphone ,my need is
I am doing a bible reader application for iPhone, I want to implement a
Ha ii everybody i am doing a reader application which has so many functionality
byte[] content = Encoding.UTF8.GetBytes(data); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = POST; request.ContentType = application/json;
I am doing a reader application in iPhone which have a loginpage the login
Doing my first SL4 MVVM RIA based application and i ran into the following

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.