ios - How can I get a UILable height dynamically with HTML Content? -
i having 1 query. googled alot not able find out solution.
i using 1 api in getting content html string.
now want set data uitextview. calculate height of uitextview firstly using
cgsize constraint = cgsizemake(width-margin - (6 * 2), 20000.0f); // size of text given cgsize made constraint cgsize size = [lbltitle.text sizewithfont:[uifont fontwithname:custom_font_name size:lbltitle.font.pointsize] constrainedtosize:constraint linebreakmode:nslinebreakbywordwrapping]; int lines = size.height / lbltitle.font.pointsize + 1; [lbltitle setframe: cgrectmake(lbltitle.frame.origin.x,lbltitle.frame.origin.y,width-margin, lbltitle.font.pointsize * lines)];
but when passing html content it's generating height more needed. solution calculate height of uitextview html text. using below code assign html text uitextview.
[txtdescription setvalue:data.desc forkey:@"contenttohtmlstring"];
thanks in advance.
you may use uiwebview
intead of uitextview
here
nsdata* htmldata = [ content datausingencoding:nsutf8stringencoding]; [webview loaddata:htmldata mimetype:@"text/html" textencodingname:@"utf-8" baseurl:[nsurl urlwithstring:@""]];
Comments
Post a Comment