Skip to content

Commit

Permalink
WebViews in both Storyboards
Browse files Browse the repository at this point in the history
code to show files in both ViewControllers
main.html and widget.html to be shown in Webviews
  • Loading branch information
janpio committed Apr 4, 2017
1 parent 52e3e84 commit cf8f06d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 18 deletions.
10 changes: 10 additions & 0 deletions Swift Today Extension Webview.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
649BE2501E940953007E4DD5 /* main.html in Resources */ = {isa = PBXBuildFile; fileRef = 649BE24F1E940953007E4DD5 /* main.html */; };
64A9AB751E9431F3001FD97F /* widget.html in Resources */ = {isa = PBXBuildFile; fileRef = 649BE2521E940968007E4DD5 /* widget.html */; };
64B8FA301E93B68C00FEB08D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B8FA2F1E93B68C00FEB08D /* AppDelegate.swift */; };
64B8FA321E93B68C00FEB08D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B8FA311E93B68C00FEB08D /* ViewController.swift */; };
64B8FA351E93B68C00FEB08D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64B8FA331E93B68C00FEB08D /* Main.storyboard */; };
Expand Down Expand Up @@ -43,6 +45,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
649BE24F1E940953007E4DD5 /* main.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = main.html; sourceTree = "<group>"; };
649BE2521E940968007E4DD5 /* widget.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = widget.html; sourceTree = "<group>"; };
64B8FA2C1E93B68C00FEB08D /* Swift Today Extension Webview.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Swift Today Extension Webview.app"; sourceTree = BUILT_PRODUCTS_DIR; };
64B8FA2F1E93B68C00FEB08D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
64B8FA311E93B68C00FEB08D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -79,6 +83,8 @@
64B8FA231E93B68C00FEB08D = {
isa = PBXGroup;
children = (
649BE24F1E940953007E4DD5 /* main.html */,
649BE2521E940968007E4DD5 /* widget.html */,
64B8FA2E1E93B68C00FEB08D /* Swift Today Extension Webview */,
64B8FA491E93C05E00FEB08D /* Today Extension */,
64B8FA461E93C05E00FEB08D /* Frameworks */,
Expand Down Expand Up @@ -212,6 +218,7 @@
buildActionMask = 2147483647;
files = (
64B8FA3A1E93B68C00FEB08D /* LaunchScreen.storyboard in Resources */,
649BE2501E940953007E4DD5 /* main.html in Resources */,
64B8FA371E93B68C00FEB08D /* Assets.xcassets in Resources */,
64B8FA351E93B68C00FEB08D /* Main.storyboard in Resources */,
);
Expand All @@ -221,6 +228,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
64A9AB751E9431F3001FD97F /* widget.html in Resources */,
64B8FA4E1E93C05E00FEB08D /* MainInterface.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -449,6 +457,7 @@
64B8FA401E93B68C00FEB08D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
64B8FA531E93C05E00FEB08D /* Build configuration list for PBXNativeTarget "Today Extension" */ = {
isa = XCConfigurationList;
Expand All @@ -457,6 +466,7 @@
64B8FA551E93C05E00FEB08D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -59,6 +79,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Expand Down
24 changes: 15 additions & 9 deletions Swift Today Extension Webview/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1421" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
Expand All @@ -18,25 +18,31 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Main" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mQn-1m-Nsu">
<rect key="frame" x="169" y="323" width="37" height="21"/>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tU0-H6-F7E">
<rect key="frame" x="47" y="57" width="321" height="260"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Main" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j81-D3-TSQ">
<rect key="frame" x="194" y="28" width="53" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="mQn-1m-Nsu" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="BlH-UA-5Fg"/>
<constraint firstItem="mQn-1m-Nsu" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="NGT-W6-pxr"/>
</constraints>
<color key="backgroundColor" red="0.52592721720406876" green="0.72383932653434857" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</view>
<connections>
<outlet property="webView" destination="tU0-H6-F7E" id="cCT-Rb-xCI"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="116" y="91.304347826086968"/>
</scene>
</scenes>
</document>
12 changes: 12 additions & 0 deletions Swift Today Extension Webview/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ import UIKit

class ViewController: UIViewController {

@IBOutlet weak var webView: UIWebView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

/*
let url = URL(string: "https://www.ft.com/");
let request = URLRequest(url: url!);
webView.loadRequest(request);
*/

let localfilePath = Bundle.main.url(forResource: "main", withExtension: "html");
let myRequest = URLRequest(url: localfilePath!);
webView.loadRequest(myRequest);
}

override func didReceiveMemoryWarning() {
Expand Down
20 changes: 12 additions & 8 deletions Today Extension/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,34 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="200"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="GcN-lo-r42">
<rect key="frame" x="20" y="8" width="280" height="184"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Hello World" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="GcN-lo-r42">
<rect key="frame" x="20" y="8" width="280" height="37"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="lightTextColor"/>
<nil key="highlightedColor"/>
</label>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="edz-VG-OWQ">
<rect key="frame" x="16" y="46" width="288" height="128"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
</subviews>
<color key="backgroundColor" red="1" green="0.26672549550016322" blue="0.47842560205088558" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="FKl-LY-JtV" firstAttribute="top" secondItem="GcN-lo-r42" secondAttribute="bottom" constant="8" symbolic="YES" id="0Q0-KW-PJ6"/>
<constraint firstItem="GcN-lo-r42" firstAttribute="leading" secondItem="S3S-Oj-5AN" secondAttribute="leading" constant="20" symbolic="YES" id="6Vq-gs-PHe"/>
<constraint firstAttribute="trailing" secondItem="GcN-lo-r42" secondAttribute="trailing" constant="20" symbolic="YES" id="L8K-9R-egU"/>
<constraint firstItem="GcN-lo-r42" firstAttribute="top" secondItem="Ft6-oW-KC0" secondAttribute="bottom" constant="8" symbolic="YES" id="mYS-Cv-VNx"/>
</constraints>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="200"/>
<connections>
<outlet property="webView" destination="edz-VG-OWQ" id="6UX-bq-0TS"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="116.8" y="105.24737631184409"/>
</scene>
</scenes>
</document>
14 changes: 13 additions & 1 deletion Today Extension/TodayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ import UIKit
import NotificationCenter

class TodayViewController: UIViewController, NCWidgetProviding {


@IBOutlet weak var webView: UIWebView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view from its nib.

/*
let url = URL(string: "https://www.ft.com/");
let request = URLRequest(url: url!);
webView.loadRequest(request);
*/

let localfilePath = Bundle.main.url(forResource: "widget", withExtension: "html");
let myRequest = URLRequest(url: localfilePath!);
webView.loadRequest(myRequest);
}

override func didReceiveMemoryWarning() {
Expand Down
7 changes: 7 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
</head>
<body>
<h1>Main</h1>
</body>
</html>
7 changes: 7 additions & 0 deletions widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
</head>
<body>
<h1>Widget</h1>
</body>
</html>

0 comments on commit cf8f06d

Please sign in to comment.