ios - UITextView changes font when detects action -


i've been looking solution problem while, , no 1 seems have come across similar issue.

basically have multiple uitextviews use detect addresses, urls, phone numbers, etc (anything can detected via uidatadectortypeall) ekevent.notes. add these uitextviews subviews of uiscrollview.

now, reason or another, once uitextview detects address or phone number , becomes actionable target, randomly draw font 2x specified font!

i've setup tests redraw views if tap. when uitextview added view initially, can see in black proper text. detection deal , becomes actionable target. stays proper size, draws @ 2x font (but still in proper frame, gets clipped).

it's straight forward, here's code below. variable correct values, frame correct, text correct, correct , 50% of time draws correct. other 50% of time becomes (apparently) 2x font! appreciated!

uitextview *locationtextview = [[uitextview alloc] init]; locationtextview.datadetectortypes = uidatadetectortypeall; locationtextview.text = location; locationtextview.font = [uifont fontwithname:@"avenirnext-regular" size:17]; locationtextview.editable = no; locationtextview.userinteractionenabled = yes; locationtextview.contentinset = uiedgeinsetsmake(-8,-8,-8,-8); locationtextview.frame =cgrectmake(kbufferleft, daysize.height, kbufferdayviewtextwidth, locationsize.height); [scrollview addsubview:locationtextview]; 

correct: http://i.imgur.com/3pj43kj.jpg

incorrect: http://i.imgur.com/dlq4gco.jpg

(not allowed post images yet, sorry.)

same exact code produced both effect. thank time.

cheers!

edit: went tttattributedlabels fix issue.

github.com/mattt/tttattributedlabel

you can set font @ <uitextfield> delegate.

-(bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text   {    locationtextview.font = [uifont fontwithname:@"avenirnext-regular" size:17]; } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -