CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.

QSWebView 1.0.1

QSWebView 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2016

Maintained by Gabriel Peart.



QSWebView 1.0.1

  • By
  • QuickSpin AB
  • QSWebView is an adapter to make your life easier when using UIWebView and WKWebView.

Features

  • [x] Easy to use and implement
  • [x] Support for WKWebView and fallback to UIWebView

Requirements

  • iOS 7.1+
  • Include the WebKit framework and set the status as optional

Install

Example

in your .h file:

// 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;

in your .m file:

// 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"];
}