techdog
techdog

Reputation: 1491

why does my uiwebview not scale correctly?

I have a uiwebview that does not scale to the correct size unless the frame is 1/2 the width and 1/2 the height. The iphone is 960x640 but the webview doesn't appear to the correct size unless I set the rectangle frame to 480x320. At 960x640 it shows only shows the bottom of the webpage.

In the html I have.

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />




- (id)initWithGameObjectName:(const char *)gameObjectName_
{
    self = [super init];
    CGRect  viewRect = CGRectMake(0,0, 480,320);
    UIView *view = UnityGetGLViewController().view;
    webView = [[UIWebView alloc] initWithFrame:viewRect];
    view.bounds=viewRect;
    webView.delegate = self;
    webView.hidden = YES;
    [view addSubview:webView];
    gameObjectName = [[NSString stringWithUTF8String:gameObjectName_] retain];
    return self;
}

Upvotes: 0

Views: 288

Answers (1)

Bharat Gulati
Bharat Gulati

Reputation: 796

you set your frame programatically for non retina screen resolution which is 480 by 320 (exactly half of retina) and xcode will automatically compile itself for retina display. It is the same way that you use imagename.png in storyboard and @2x images are picked by xcode for retina.

Upvotes: 1

Related Questions