I have some views that use core text to drag text with some attributes. In this, I am searching for URL and making them blue. The idea is not to get all the overheads of UIWebView
to get a clickable link. Once the user faucets on that link (not the entire table view cell), I want to turn off a representative method which will then be used to present a model view, which has web view by visiting that URL.
I am saving paths and strings as an example variable of the view, and the drawing code is in -drawRect:
(I have left it for brevity).
My touch handler However, incomplete time, I am not expecting it to be below:
- (zero) touch touch: (nsset *) event Touches with: (UIEvent *) event {UITT * touch = [touches any object]; CG point point = [touch location invoice: self]; CGContextRef Reference = UIGraphicsGetCurrentContext (); NSLog (@ "attribisting =% @", auto. Retread string); CTFramesetterRef Frameset = CTFramesetterCreateWithAttributedString ((CFAttributedStringRef) self.attribString); CTFrameRef ctframe = CTFramesetterCreateFrame (Frameset, CFRMakeMake (0, Self Retriebrating Lamp), Attitudes, Faucets); CFArrayRef line = CTFrame gateline (CTFR); (Cfindx I = 0; I & lt; CFRAT gatecount (line); I ++) {CT linearf line = CfRRAAgeTuAlTindex (line, I); CGRTP linebound = CTLGetIMAJound (line, reference); // Check if tap was on our line (CGRTC content points (linebones, point)) {NSLog (@ "tape line"); CFArrayRef Run = CTLineGetGlyphRuns (line); (Cfidxxj = 0; j and lt; cfrAggett (run); J ++) {CTRUN RF run = CFRRAgate valuedindex (run, j); Cfranj URL string string = ctrngtstringrange (runs); CGRT runbond = CTRGet image bound (run, context, URL stringing); If (CGRCTCentsPoint (runbones, point)) {NSLog (@ "tape run"); CFIndex * buffer = molec (size (cfindex) * urlStringRange.length); CTRunGetStringIndices (run, urlStringRange, buffer); // TODO: Map the Glyph Index to index the string & amp; Ask this representative}}}}}
This is not the most beautiful code at the moment, I'm still trying to work on it, so forgive the code quality .
The problem I am facing is that, when I tap outside the link, what I hope, happens: does not remove anything.
However, I expect to print "tap line"
if I tap on the same line, the link is on, which is not, and I "Tape Line"
and "Tape Run"
If I tap on the URL then to be printed.
I am unsure about where to take this forward, on the issue, the resources I have seen for the resolution are Koko specific (which is almost not fully implemented), or There is a lack of information on this specific case.
I typically take the pointer to the document, which in detail how to find out whether the core text on the touch code is within the range of drawing, but at this point, I just want to redo Please solve this problem, so any help would be greatly appreciated.
UPDATE : I've limited my problem to the point of coordination. I've flipped the coordinates (and not as shown above) and the problem I am facing is that I hope the tape is registered, but the coordinate location is flipped, and I can not flip it back .
I did this to get the string character index from touch position only. Line number In this case I will:
- (zero) touch touch: (NSSET *) touches the event: (UEIVEMENT *) event {NSLog (@ "Touch Ended"); UIT * touch = [touches any object]; CGPoint pnt = [Touch Location InViv: Self]; CGPET reversepoint = CPPXMake (PNT.X, self.frame.ize-height-pnt.y); CFArrayRef line = CTFFrame gateline (ctFrame); CGPoint * lineOrigins = malloc (sgpoin) * CFRAgatecount (line)); CTFromGetline.org (CTFFrame, CFRMakeMake (0,0), LineGridins); (Cfindx I = 0; I & lt; CFRAT gatecount (line); I ++) {CT linearf line = CFRAAgeTuAlTindex (line, I); CGPint Origin = Lineoffins [I]; If (reversepoint.y & gt; orig.y) {NSInteger index = CTLineGetStringIndexForPosition (line, reverse point); NSLog (@ "index% d", index); break; }} Free (line agrees); }
Comments
Post a Comment