我正在使用指向我网站的小型UIWebView iOS应用程序,我正确设置了视口,在safari中看起来很棒,或者我在主屏幕上添加书签
但由于某种原因,当我将它插入UIWebView时,一切都变得更大,我试图取消选中" Scale to Fit"对于界面构建器中的UIWebView,但是没有帮助
如何让WebView在Safari的同一方面进行扩展/显示?
WebSite标题中的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<script>
function goBack() {
window.history.back();
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<meta charset="UTF-8" />
<title>SITE TITLE</title>
<link rel="shortcut icon" href="{$url}/favicon.ico" />
<link href="{$url}/{$theme_path}/{$theme_name}/style.css" rel="stylesheet" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="HandheldFriendly" content="true" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<link rel="apple-touch-icon-precomposed" href="WEBAPPICON.png"/>
</head>
UIWebView代码:
//
// ViewController.m
// Webview
//
// Created by Stewart Crainie on 10/02/2014.
// Copyright (c) 2014 Stewart Crainie. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize receivedData, theConnection, webSite, back, forward, stop, refresh;
- (void)viewDidLoad
{
[self loadWebsite];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)loadWebsite {
NSString *fullURL = @"http://WEBVITEURL";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestWebsite = [NSURLRequest requestWithURL:url];
[webSite loadRequest:requestWebsite];
}
- (void)updateButtons
{
self.forward.enabled = self.webSite.canGoForward;
self.back.enabled = self.webSite.canGoBack;
self.stop.enabled = self.webSite.loading;
}
#pragma mark MBProgressHUDDelegate methods
- (void)hudWasHidden:(MBProgressHUD *)hud {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
HUD = nil;
}
-(void)stopLoading {
NSLog(@"Stop Pushed");
[HUD hide:YES];
[webSite stopLoading];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"could not load the website caused by error: %@", error);
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"%@", [error localizedDescription]]
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[message show];
[HUD hide:YES];
[webSite stopLoading];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
[self updateButtons];
[HUD hide:YES];
[webSite stopLoading];
}
-(void)webViewDidStartLoad:(UIWebView *)webView {
[self updateButtons];
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.delegate = self;
HUD.mode = MBProgressHUDModeIndeterminate;
HUD.labelText = @"Loading...";
}
@end