UIWebView landscape transfer does not fill the view

I have a problem with UIWebView. When a view loads it, loads in any direction, perfectly fills the entire page, etc.

However, tell me if I download it in the portrait, and then rotate the device, the web view does not fill out completely to the right side, and I can’t understand why.

This is my view on the boot method.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib

    if  ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait){

        self.measurementsWebView.frame = CGRectMake(0, 0, 320, 367);

    }else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight){

        self.measurementsWebView.frame = CGRectMake(0, 0, 480, 218);
    }

    NSString *path = [[NSBundle mainBundle] pathForResource:@"measurements" ofType:@"png"];
    [measurementsWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
    measurementsWebView.scalesPageToFit = YES;

}

If I look in the interface constructor, I try to find a panel that allows me to set the expanding width or what you ever call it, but all I see is that.

enter image description here

any help would be greatly appreciated

+5
source share
3 answers

, , :

measurementsWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

webView, (, , , , measurementsWebView). , :

auto-resize from nib

, .

+4

viewDidLoad - .

, , viewDidLayoutSubviews, , .

-(void)viewDidLayoutSubviews {

    [super viewDidLayoutSubviews];

    self.measurementsWebView.frame = self.view.bounds;

}
+3

In Interface Builder, from the drop-down menu that says "Layout Rectangle", click it and select "Rectangle Frame."

Alternatively, you can override the method willAnimateRotationToInterfaceOrientation:in your view controller and manually set the coordinates / size manually, as was done in viewDidLoad.

+1
source

All Articles