To participate in a game has a title, like the headline, in the Uitextview touch to find the corresponding text, the game can also check the information, when doing is to hold the mentality of playing to try and did not seriously do, did not check to eat, Came back from work last night thinking about this problem found that there is quite a level of this question is not simple, I tried to do the next, or in the stack overflow found in the answer. Http://stackoverflow.com/questions/19332283/detecting-taps-on-attributed-text-in-a-uitextview-in-ios
Oneself also tried, also quite good, originally thought that iOS basically do not have to learn, it seems to learn a lot of many, really rise posture.
Here is the demo record of my Test.
_oxtextview=[[oxtouchtextview Alloc]initwithframe:cgrectmake (0)]; _oxtextview.text=@ "The Ape-ring is an Internet technology talent service platform, focusing on technical personnel evaluation, code to help enterprises quickly identify technical personnel: Candidates to accept online testing challenges, the use of machine automatic volume, programming data collection, The use of advanced technology capability recognition algorithm, accurately identify the candidate's real technical ability, the formation of a comprehensive programming skills assessment report and Analysis matrix, the results of feedback to users and companies, greatly saving time and effort. In addition, the Ape Circle self-developed Android, iOS online cloud compiler engine, can support users in the cloud (browser) to write code, in the world leading position. "; [Self.view Addsubview:_oxtextview];
#import "OXTouchTextView.h"@implementationOxtouchtextview- (ID) initWithFrame: (CGRect) frame { self=[Super Initwithframe:frame]; if(self) {}returnSelf ;}- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event { // the//start writing code, when the touch operation starts, gets the word that the character of the current touch position belongs to. and display it with Uialertview (hint: Touch position needs to be adjusted down by 10 points to align with the text element)Uitouch *touch =[touches anyobject]; Cgpoint TouchPoint=[Touch locationinview:self]; Nsinteger Characterindex=[Self.layoutmanager characterindexforpoint:touchpoint InTextContainer:self.textContainer Fractionofdistancebetweeninsertionpoints:null]; if(characterindex<self.text.length) {nsstring*s=[self.text Substringwithrange:nsmakerange (Characterindex,1)]; NSLog (@"%@", s); } //End_code[Super Touchesbegan:touches Withevent:Event];}@end
Test results:
Touch Uitextview to find the text of the touch point