1

I am making an app which has a UIWebView, in which I need to display the mobile version of an SE question, However, the page seems to have a minimum width - 768 to be precise - which just happens to be the width of the tablet itself.

This is the code I am using:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://stackoverflow.com/questions/7312584/inject-a-local-javascript-into-uiwebview"]]];
}

Nothing fancy. My web view, however, has a width just a little smaller, which means that there is just a little bit of ugly side-scrolling involved.

How do I make the mobile site ignore that I'm on an iPad (it works fine on an iPhone), and just scale to whatever size I make the UIWebView?

Undo
  • 25,519
  • 37
  • 106
  • 129

1 Answers1

1

It knows what you are by the User Agent, which you can see how to do in this question

Change User Agent in UIWebView (iPhone SDK)

Alternatively, you could inject JavaScript into the page after it loads and change the width of the body or main div

Injecting JavaScript into UIWebView

To set the body width, see this question

set body width in px?

Community
  • 1
  • 1
Lou Franco
  • 87,846
  • 14
  • 132
  • 192