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 below
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.