-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebViewController.swift
More file actions
40 lines (37 loc) · 1.15 KB
/
WebViewController.swift
File metadata and controls
40 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// WebViewController.swift
// Nerdfeed
//
// Created by Troy Abel on 10/23/14.
// Copyright (c) 2014 Troy Abel. All rights reserved.
//
import UIKit
import WebKit
class WebViewController: UIViewController {
var webView: WKWebView!
var URL: NSURL?
override func viewDidLoad() {
super.viewDidLoad()
webView = WKWebView(frame: view.bounds)
webView.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addSubview(webView)
// Setup web view constraints
var formatString = "H:|[webView]|"
var constraints = NSLayoutConstraint.constraintsWithVisualFormat(formatString,
options: nil,
metrics: nil,
views: ["webView": webView])
view.addConstraints(constraints)
formatString = "V:|[webView]|"
constraints = NSLayoutConstraint.constraintsWithVisualFormat(formatString,
options: nil,
metrics: nil,
views: ["webView": webView])
view.addConstraints(constraints)
// Load URL if there is one
if let urlToLoad = URL {
let req = NSURLRequest(URL: urlToLoad)
webView.loadRequest(req)
}
}
}