xcode - When trying to get dynamically created UILabel to wrap, text disappears -


i'm trying display description text varies couple of words hundred words. i've set uilabel wrap compensate using code below

    desctext.frame = cgrect(x: 115, y: 160, width: 465, height: 21)          desctext.textalignment = nstextalignment.left     desctext.numberoflines = 0     desctext.linebreakmode = nslinebreakmode.bywordwrapping     desctext.sizetofit()     desctext.text = text     dtlview.addsubview(desctext) 

if remove desctext.sizetofit() text reappears won't wrap, same happens if try set height in cgrect cgfloat.max.

what missing?

make use of bycharwrapping instead of using bywordwrapping

also make sure call sizetofit() after assigning text.

desctext.linebreakmode = nslinebreakmode.bycharwrapping desctext.text = text desctext.sizetofit() 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -