Getting iPhone's mobile twitter webapp inside UIWebView

后端 未结 1 977
礼貌的吻别
礼貌的吻别 2021-01-20 21:05

Ok, here\'s the scenario: I\'m building an iPad app that will display an UIWebView, width = 320 pixels (or points now). It will wind of a \"widget\" inside the app.

1条回答
  •  生来不讨喜
    2021-01-20 21:45

    This seems to be a better solution because it doesn't require reloading the HTML: https://stackoverflow.com/a/6104537/1449618

    The following works in my app on iPad.

    Set self as UIWebViewDelegate then:

    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.querySelector('meta[name=viewport]').setAttribute('content', 'width=%d;', false); ", (int)webView.frame.size.width]];
    }
    

    0 讨论(0)
提交回复
热议问题