QSWebView 1.0.1

QSWebView 1.0.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年1月

Gabriel Peart维护。



QSWebView 1.0.1

  • 作者:
  • QuickSpin AB
  • QSWebView 是一个适配器,可让您在使用 UIWebView 和 WKWebView 时变得更简单。

特性

  • [x] 使用及实现简单
  • [x] 支持 WKWebView 并回退到 UIWebView

要求

  • iOS 7.1+
  • 包含 WebKit 框架并将状态设置为 可选

安装

示例

在您的 .h 文件中

// Needed for UIViewController, UIWebViewDelegate, and UIView
#import <UIKit/UIKit.h>
// Needed for WKNavigationDelegate and WKUIDelegate
#import <WebKit/WebKit.h>
// Used to define the webView property below
#import "QSWebViewAdapter.h"

// The main web view that is set up in the viewDidLoad method.
@property (nonatomic) UIView <QSWebViewAdapter> *webView;

在您的 .m 文件中

// Required for calls to UIWebView and WKWebView to "see" the QSUIWebView and 
QSWKWebView categories
#import "UIWebView+QSUIWebView.h"
#import "WKWebView+QSWKWebView.h"
#import "QSWebViewFactory.h"

- (void)viewDidLoad
{
    [super viewDidLoad];

    // If it is present, create a WKWebView. If not, create a UIWebView.
    _webView = GetQSWebViewWithFrame([[self view] bounds]);

    // Add the webView to the current view.
    [[self view] addSubview: [self webView]];

    // Assign this view controller as the delegate view.
    // The delegate methods are below, and include methods for UIWebViewDelegate, WKNavigationDelegate, and WKUIDelegate
    [[self webView] setDelegateViews: self];

    // Ensure that everything will resize on device rotate.
    [[self webView] setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [[self view]    setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

    // Just to show *something* on load, we go to our favorite site.
    [[self webView] loadRequestFromString:@"http://www.google.com"];
}