ios - AMAttributedHighlightLabel not working properly in UITable View? -
i have use amattributedhighlightlabel show "#"hashtag , "@"mention name clickable amattributedhighlightlabel work in uitable view. call touchesbegan method not found word. not fire delegate method.table label image link
link third party custom label amattributedhighlightlabel
code
- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [[event alltouches] anyobject]; cgpoint touchlocation = [touch locationinview:self]; int count = [touchablelocations count]; (int i=0; < count; i++) { if (cgrectcontainspoint([[touchablelocations objectatindex:i] cgrectvalue], touchlocation)) { nsmutableattributedstring *newattrstring = [self.attributedtext mutablecopy]; [newattrstring removeattribute:nsforegroundcolorattributename range:[[touchablewordsrange objectatindex:i] rangevalue]]; nsstring *string = [touchablewords objectatindex:i]; if([string hasprefix:@"@"]) [newattrstring addattribute:nsforegroundcolorattributename value:self.selectedmentiontextcolor range:[[touchablewordsrange objectatindex:i] rangevalue]]; else if ([string hasprefix:@"#"]) [newattrstring addattribute:nsforegroundcolorattributename value:selectedhashtagtextcolor range:[[touchablewordsrange objectatindex:i] rangevalue]]; else if ([string hasprefix:@"http://"]) [newattrstring addattribute:nsforegroundcolorattributename value:selectedlinktextcolor range:[[touchablewordsrange objectatindex:i] rangevalue]]; else if ([string hasprefix:@"https://"]) [newattrstring addattribute:nsforegroundcolorattributename value:selectedlinktextcolor range:[[touchablewordsrange objectatindex:i] rangevalue]]; else if ([string hasprefix:@"www."]) [newattrstring addattribute:nsforegroundcolorattributename value:selectedlinktextcolor range:[[touchablewordsrange objectatindex:i] rangevalue]]; self.attributedtext = newattrstring; currentselectedrange = [[touchablewordsrange objectatindex:i] rangevalue]; currentselectedstring = [touchablewords objectatindex:i]; } } }
i have face issue in amattributedhighlightlabel library have move sttweetlabel library.this library have found issue in sttweetlabel when emoji characters use in text cutting down text on label use code of below
#import <coretext/coretext.h>
- (cgfloat)heightstringwithemojis:(nsstring*)str fonttype:(uifont *)uifont forwidth:(cgfloat)width { // text cfmutableattributedstringref attrstring = cfattributedstringcreatemutable(kcfallocatordefault, 0); cfattributedstringreplacestring (attrstring, cfrangemake(0, 0), (cfstringref) str ); cfindex stringlength = cfstringgetlength((cfstringref) attrstring); // change font ctfontref ctfont = ctfontcreatewithname((__bridge cfstringref) uifont.fontname, uifont.pointsize, null); cfattributedstringsetattribute(attrstring, cfrangemake(0, stringlength), kctfontattributename, ctfont); // calc size ctframesetterref framesetter = ctframesettercreatewithattributedstring(attrstring); cfrange fitrange; cgsize framesize = ctframesettersuggestframesizewithconstraints(framesetter, cfrangemake(0, 0), null, cgsizemake(width, cgfloat_max), &fitrange); cfrelease(ctfont); cfrelease(framesetter); cfrelease(attrstring); return framesize.height + 5; }
Comments
Post a Comment