iPhone UIWebView width does not fit after zooming operation + UIInterfaceOrientation change

前端 未结 8 1510
庸人自扰
庸人自扰 2020-12-02 19:20

I created a bare bones iPhone app with a UIWebView (Scales Page to Fit = YES, shouldAutorotateToInterfaceOrientation = YES) and loaded a webpage, e.g. https://stackoverflow.

8条回答
  •  春和景丽
    2020-12-02 20:08

    I've tried the solution from M Penades and this seems to work for me as well.

    The only issue that I'm experiencing is that when running this on a 3Gs the rotation is unfortunately not very smooth.

    I'm therefore now using a different approach:

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    
    CGFloat scale = browserWebView.contentScaleFactor;
    NSString *javaStuff = [NSString stringWithFormat:@"document.body.style.zoom = %f;", scale];
    [browserWebView stringByEvaluatingJavaScriptFromString:javaStuff];
    
    }
    

    Best Regards,
    Ralph

提交回复
热议问题