UIWebView scale to parent UIView (no IB)

Discussion in 'iOS Programming' started by whitehexagon, Jun 21, 2009.

  1. whitehexagon macrumors regular


    May 12, 2007
    xcode newbie!

    I have a UIView that I can change the size of programmatically. Inside is a UIWebView that is pointing to a jpg (no html). Currently I only see the top left corner of the jpeg. I'm wondering if I should wrap the content into some custom html were I can set the correct size?, or if the UIWebView has some hidden magic for 'scale and fill parent view'. It needs to continue to fill when the parent UIView grows/shrinks in size.

    Although I'm sure my next question with either method is controlling the aspect ratio. If I want to maintain the correct asspect ratio, then I will need someway to specify where blank space should be inserted, eg like widescreen TV black bars.

    And for bonus points I'm hoping pinch/zoom will work out of the box... Although I'm finding testing pinch in simulator a pain (only seems to pinch from center of display?).

    btw this is programatic, not IB!
  2. whitehexagon thread starter macrumors regular


    May 12, 2007
    update: I found:

    myWebView.scalesPageToFit = YES;
    which seems to help to a point. My image is 640x480 but UIWebView seems to be scaling it down to 1/4 that size. How do I control that scaling? I can't wrap the html as I originally thought becuase I'm retriving the image with basic authentication.

Share This Page