iphone - UIWebview resize height to fit content -


i know has been asked many times can not work. in short uiwebview pulls in html has none fixed height (width same), want height change accordingly.

i have tried number of fixes have found online problem webview change correct size brief second , in flicks original size.

i should point out view invoked segue, thing can think different! wondering if code works when segue finishes it's crossfade, flip or whatever redraws webview.

here current code (as have tried many fixes including java versions of same), have played scalespagetofit , srollenabled plus few of ticks in storyboard.

-(void)webviewdidfinishload:(uiwebview *)webview {     nslog(@"starting size : %f", headerwebview.frame.size.height);      headerwebview.scalespagetofit = yes;     headerwebview.scrollview.scrollenabled = no;     cgrect frame = headerwebview.frame;      frame.size.width = frame.size.width; // used test, put 200 in , changes flicks     frame.size.height = 1;      headerwebview.frame = frame;     frame.size.height = headerwebview.scrollview.contentsize.height;     headerwebview.frame = frame;      nslog(@"finished size : %f", headerwebview.frame.size.height); } 

the logs say;

starting size : 176.000000 finished size : 246.000000

anyone got idea why webview appears fine long enough me notice , "shrink" back?

anyone got idea why webview appears fine long enough me notice , "shrink" back?

i appears fine because showing changes happening. why not hide web view @ earlier point in view lifecycle or in webviewdidfinishloading? sharing layout settings ib in case may provide further assistance. please advise if helps or whether additional information needed. using springs , struts rather auto layout. try these method see if works you.

hiding web view data loads prevents users seeing until of settings/data in place.

    nsstring *path = [[nsbundle mainbundle] bundlepath];     nsurl *baseurl = [nsurl fileurlwithpath:path];      [webview setalpha:0];     [webview loaddata:[datastring datausingencoding:nsutf8stringencoding] mimetype:@"text/html" textencodingname:@"utf-8"  baseurl:baseurl];      [uiview animatewithduration:0.1 animations:^{          [webview setalpha:1.0];      } completion:nil]; 

web view springs , struts web view settings


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -