Ok....just doing some self education. Thought I would try and create what I thought was a simple webview of youtube. So the webview opens Youtube but the content is way off the screen. It's like the page is being delivered to a larger device or something.
I've tried multiple sites like google and still same result, text off the screen or images off the screen. I was thinking it would shrink after all when I go to the site using Safari on the iPhone it displays properly but through an app/webview I get:
Here is my viewcontroller.m:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
webPage.delegate = self;
webPage.scalesPageToFit = NO;
NSString *website = @"http://www.youtube.com:";
NSURL *url = [NSURL URLWithString:website];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webPage loadRequest:request];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webPage stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.querySelector('meta[name=viewport]').setAttribute('content', 'width=%d;', false); ", (int)webPage.frame.size.width]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Here is my viewcontroller.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIWebViewDelegate>{
IBOutlet UIWebView *webPage;
}
@end