I have a custom uitableviewcell with several labels, and I would like some of them to automatically determine their frame (width) based on the content (text). I do not know how to do that. I tried to set a fixed label frame after applying autoresizingMask as well, but that doesn't do the trick. Any * sample pointer?
Use the following method:
CGSize *size = [label.text sizeWithFont:fontOfLabelText]; float widthOfLabel = size.width;
size.width will return the actual width that the text on the label will occupy on the screen. Set the width of the label to the width of the text.
,
[label sizeToFit];
.
If you just want to make the label fit in multiple lines, you should say:
cell.textLabel.numberOfLines = 0;
However, I'm not sure if this is the one you want ... Usually, if the content is text, that will be what you want.
Source: https://habr.com/ru/post/1748744/More articles:Is the .NET Framework installed on an existing VB6 or COM runtime? - .nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1748740/how-do-i-make-calls-to-a-wcf-service-with-jquery-ajax-from-an-ssl-secured-page&usg=ALkJrhhapm6KDV1otDT1kqpcWbIPhYJSpAIs there a way to check if the / Sub function is available in VB6? - vb6What is in scala -android.jar? - javaWhat happened to my HtmlHelper? - asp.net-mvchttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1748745/how-to-i-correctly-add-brackets-to-this-code&usg=ALkJrhhSHjgg12YOQmPc2AQAlpSOuMIhPQHow to get html helper password to display password if validation fails - c #Android compatibility with Restlet / JSON / Jackson - javaWhy can't I create a RESTful web service in an ejb module? - javaCross-platform tips, tricks and Gotchas - cross-platformAll Articles