ios - How can I adjust UILabel height to fit the size? -


i know io7 , later , boundingrectwithsize can work. in order fit ios version. use sizethatfits calculate.following code:

self.detaillabel.text=@"visit bbc news up-to-the-minute news, breaking news, video, audio , feature stories. bbc news provides trusted";        self.detaillabel.linebreakmode = nslinebreakbywordwrapping;  cgsize size =[self.detaillabel sizethatfits:cgsizemake(287, maxfloat)]; //287 label's width set in storyboard        [self.detaillabel setframe:cgrectmake(self.detaillabel.frame.origin.x, self.detaillabel.frame.origin.y, self.detaillabel.frame.size.width, size.height)];  self.detaillabel.layer.bordercolor=[[uicolor blackcolor] cgcolor];  self.detaillabel.layer.borderwidth=1;

and result is: enter image description here

the last 2 word "provides trusted" missing!!!!!!

how ever when append word

self.detaillabel.text=@"visit bbc news up-to-the-minute news, breaking news, video, audio , feature stories. bbc news provides trusted world and"; 

the result : enter image description here

my storyboard design is: enter image description here

enter image description here

i guess wrong line break.. when next line text not long enough next line miss..

try code

self.detaillabel.text=@"visit bbc news up-to-the-minute news, breaking news, video, audio , feature stories. bbc news provides trusted";         self.detaillabel.numberoflines=0;     self.detaillabel.linebreakmode=nslinebreakbywordwrapping; [self.detaillabel sizetofit]; 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -