views:

626

answers:

2

Hi all together,

I'm quite new to Iphone programming, and already did some search on the internet trying to get some usefull help.

What I would like to do is, if my detailed view gets called I would like to highlight just a Part of the text of the UITextView Element.

Lets say the text within the UITextView is: blatextbla Then I would like to highlight dynamically only "text" or "late" or whatever comes to the users mind.

Any suggestions on how to do that?

thanks in advance!

A: 

you'll need to get the ranges within your text where the text to be highlighted starts and ends then use:

NSRange selection = [yourNSString rangeOfString:@"late"]; if( selection.location != NSNotFound ){ myTextView.selectedRange = selection; }

I've never tried to select multiple ranges within a UITextView, so not sure if that's possible. I doubt its possible...

wkw
A: 

USE THIS MY DEAR - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text THIS IS A BUILT IN FUNCTION THROUGH WHICH YOU CAN FIND AND REPLACE THE TEXT IN TEXTVIEW

UMER