Skip to content

Commit 0992a23

Browse files
committed
swift 3
1 parent d290771 commit 0992a23

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

EFIntroVideoViewController/Classes/EFIntroVideoViewController.swift

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class EFIntroVideoViewController: UIViewController {
1515
var playerLayer: AVPlayerLayer!
1616
var playerView: UIView!
1717

18-
@IBInspectable var nextViewControllerIdentifier: String = ""
18+
@IBInspectable var nextViewControllerIdentifier: String? = nil
1919
@IBInspectable var storyboardName:String = "Main"
2020
@IBInspectable var videoPath:String = ""
2121
@IBInspectable var videoType:String = ""
@@ -58,17 +58,22 @@ class EFIntroVideoViewController: UIViewController {
5858
playerView.layer.addSublayer(playerLayer)
5959
player?.seek(to: kCMTimeZero)
6060
player?.play()
61+
62+
guard let nextIdentifier = self.nextViewControllerIdentifier else {
63+
return
64+
}
65+
self.nextViewControllerIdentifier = nextIdentifier
66+
6167
Timer.scheduledTimer(timeInterval: videoTime, target: self, selector: #selector(openNextViewController), userInfo: nil, repeats: false)
6268
}
6369

64-
func openNextViewController() {
70+
func openNextViewController() {
6571
UIView.animate(withDuration: videoTransitionTime, animations: {
6672
self.playerView.alpha = 0
6773
}, completion: { (completed) in
68-
let identifier = self.nextViewControllerIdentifier
6974
let storyboard = UIStoryboard(name: self.storyboardName, bundle: nil)
7075
self.playerView.removeFromSuperview()
71-
let next = storyboard.instantiateViewController(withIdentifier: identifier)
76+
let next = storyboard.instantiateViewController(withIdentifier: self.nextViewControllerIdentifier!)
7277
self.present(next, animated: self.animated, completion: nil)
7378
})
7479
}

Example/EFIntroVideoViewController/Base.lproj/Main.storyboard

+61-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
</view>
2222
<userDefinedRuntimeAttributes>
2323
<userDefinedRuntimeAttribute type="string" keyPath="storyboardName" value="Main"/>
24-
<userDefinedRuntimeAttribute type="string" keyPath="nextViewControllerIdentifier" value="ViewController"/>
2524
<userDefinedRuntimeAttribute type="string" keyPath="videoPath" value="intro"/>
2625
<userDefinedRuntimeAttribute type="string" keyPath="videoType" value="mp4"/>
2726
<userDefinedRuntimeAttribute type="number" keyPath="videoTime">
@@ -31,6 +30,7 @@
3130
<real key="value" value="1"/>
3231
</userDefinedRuntimeAttribute>
3332
<userDefinedRuntimeAttribute type="boolean" keyPath="animated" value="YES"/>
33+
<userDefinedRuntimeAttribute type="string" keyPath="nextViewControllerIdentifier" value="ViewController"/>
3434
</userDefinedRuntimeAttributes>
3535
</viewController>
3636
<placeholder placeholderIdentifier="IBFirstResponder" id="4VT-VH-AMu" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -54,17 +54,75 @@
5454
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
5555
<nil key="highlightedColor"/>
5656
</label>
57+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xaV-hP-0rz">
58+
<state key="normal" title="Show Again"/>
59+
<connections>
60+
<segue destination="8ca-u7-Sd9" kind="show" id="c4I-l0-90s"/>
61+
</connections>
62+
</button>
5763
</subviews>
5864
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
5965
<constraints>
66+
<constraint firstAttribute="trailing" secondItem="xaV-hP-0rz" secondAttribute="trailing" constant="110" id="BQO-Su-CwZ"/>
6067
<constraint firstItem="BZq-wl-8MO" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="KOp-00-mKF"/>
61-
<constraint firstItem="BZq-wl-8MO" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="buV-nl-Wdq"/>
68+
<constraint firstItem="xaV-hP-0rz" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="110" id="SfC-a2-LqG"/>
69+
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="BZq-wl-8MO" secondAttribute="bottom" constant="277" id="XiQ-XD-sjM"/>
70+
<constraint firstItem="BZq-wl-8MO" firstAttribute="top" secondItem="xaV-hP-0rz" secondAttribute="bottom" constant="35" id="z82-cc-eV0"/>
6271
</constraints>
6372
</view>
73+
<navigationItem key="navigationItem" id="5ha-TM-oYU"/>
6474
</viewController>
6575
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
6676
</objects>
67-
<point key="canvasLocation" x="262" y="407"/>
77+
<point key="canvasLocation" x="1200.8" y="406.14692653673166"/>
78+
</scene>
79+
<!--Intro Video View Controller-->
80+
<scene sceneID="A01-5g-x38">
81+
<objects>
82+
<viewController id="8ca-u7-Sd9" customClass="EFIntroVideoViewController" customModule="EFIntroVideoViewController" sceneMemberID="viewController">
83+
<layoutGuides>
84+
<viewControllerLayoutGuide type="top" id="6Ha-xP-8FI"/>
85+
<viewControllerLayoutGuide type="bottom" id="J78-mY-o28"/>
86+
</layoutGuides>
87+
<view key="view" contentMode="scaleToFill" id="wcR-yt-QyO">
88+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
89+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
90+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
91+
</view>
92+
<userDefinedRuntimeAttributes>
93+
<userDefinedRuntimeAttribute type="string" keyPath="storyboardName" value="Main"/>
94+
<userDefinedRuntimeAttribute type="string" keyPath="videoPath" value="intro"/>
95+
<userDefinedRuntimeAttribute type="string" keyPath="videoType" value="mp4"/>
96+
<userDefinedRuntimeAttribute type="number" keyPath="videoTime">
97+
<real key="value" value="10"/>
98+
</userDefinedRuntimeAttribute>
99+
<userDefinedRuntimeAttribute type="boolean" keyPath="animated" value="YES"/>
100+
<userDefinedRuntimeAttribute type="number" keyPath="videoTransitionTime">
101+
<real key="value" value="1"/>
102+
</userDefinedRuntimeAttribute>
103+
</userDefinedRuntimeAttributes>
104+
</viewController>
105+
<placeholder placeholderIdentifier="IBFirstResponder" id="P5N-yn-Rv4" userLabel="First Responder" sceneMemberID="firstResponder"/>
106+
</objects>
107+
<point key="canvasLocation" x="1868" y="405.24737631184411"/>
108+
</scene>
109+
<!--Navigation Controller-->
110+
<scene sceneID="Znn-9S-DPt">
111+
<objects>
112+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="O2d-un-Gbb" sceneMemberID="viewController">
113+
<toolbarItems/>
114+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="IKe-Gn-TXc">
115+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
116+
<autoresizingMask key="autoresizingMask"/>
117+
</navigationBar>
118+
<nil name="viewControllers"/>
119+
<connections>
120+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="4Ch-KQ-eEX"/>
121+
</connections>
122+
</navigationController>
123+
<placeholder placeholderIdentifier="IBFirstResponder" id="ouQ-HD-jRb" userLabel="First Responder" sceneMemberID="firstResponder"/>
124+
</objects>
125+
<point key="canvasLocation" x="261.60000000000002" y="406.14692653673166"/>
68126
</scene>
69127
</scenes>
70128
</document>

0 commit comments

Comments
 (0)