Skip to content
This repository was archived by the owner on May 18, 2021. It is now read-only.

Commit 4f27aef

Browse files
author
石峰铭
committed
remove extra delegate
1 parent 84e8133 commit 4f27aef

File tree

89 files changed

+4259
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4259
-87
lines changed

Project 03 - PlayLocalVideo/PlayLocalVideo.xcodeproj/project.pbxproj

-8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
8214D85E1DE74A900001FC55 /* PlayLocalVideoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8214D85D1DE74A900001FC55 /* PlayLocalVideoUITests.swift */; };
1717
8214D86D1DE74BC70001FC55 /* emoji zone.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 8214D86C1DE74BC70001FC55 /* emoji zone.mp4 */; };
1818
8214D86F1DE7C8AC0001FC55 /* VideoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8214D86E1DE7C8AC0001FC55 /* VideoCell.swift */; };
19-
C4C780801DE87316005E9C84 /* VideoCellDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C7807F1DE87316005E9C84 /* VideoCellDataSource.swift */; };
20-
C4EA5A111DE876AE00170698 /* VideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EA5A101DE876AE00170698 /* VideoModel.swift */; };
2119
/* End PBXBuildFile section */
2220

2321
/* Begin PBXContainerItemProxy section */
@@ -53,8 +51,6 @@
5351
8214D85F1DE74A900001FC55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5452
8214D86C1DE74BC70001FC55 /* emoji zone.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "emoji zone.mp4"; sourceTree = "<group>"; };
5553
8214D86E1DE7C8AC0001FC55 /* VideoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCell.swift; sourceTree = "<group>"; };
56-
C4C7807F1DE87316005E9C84 /* VideoCellDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCellDataSource.swift; sourceTree = "<group>"; };
57-
C4EA5A101DE876AE00170698 /* VideoModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoModel.swift; sourceTree = "<group>"; };
5854
/* End PBXFileReference section */
5955

6056
/* Begin PBXFrameworksBuildPhase section */
@@ -108,13 +104,11 @@
108104
8214D83D1DE74A900001FC55 /* AppDelegate.swift */,
109105
8214D83F1DE74A900001FC55 /* ViewController.swift */,
110106
8214D86E1DE7C8AC0001FC55 /* VideoCell.swift */,
111-
C4C7807F1DE87316005E9C84 /* VideoCellDataSource.swift */,
112107
8214D8411DE74A900001FC55 /* Main.storyboard */,
113108
8214D8441DE74A900001FC55 /* Assets.xcassets */,
114109
8214D86B1DE74BC70001FC55 /* MovieSource */,
115110
8214D8461DE74A900001FC55 /* LaunchScreen.storyboard */,
116111
8214D8491DE74A900001FC55 /* Info.plist */,
117-
C4EA5A101DE876AE00170698 /* VideoModel.swift */,
118112
);
119113
path = PlayLocalVideo;
120114
sourceTree = "<group>";
@@ -285,8 +279,6 @@
285279
files = (
286280
8214D8401DE74A900001FC55 /* ViewController.swift in Sources */,
287281
8214D83E1DE74A900001FC55 /* AppDelegate.swift in Sources */,
288-
C4C780801DE87316005E9C84 /* VideoCellDataSource.swift in Sources */,
289-
C4EA5A111DE876AE00170698 /* VideoModel.swift in Sources */,
290282
8214D86F1DE7C8AC0001FC55 /* VideoCell.swift in Sources */,
291283
);
292284
runOnlyForDeploymentPostprocessing = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "Yes"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No"
12+
symbolName = ""
13+
moduleName = "">
14+
<Locations>
15+
</Locations>
16+
</BreakpointContent>
17+
</BreakpointProxy>
18+
</Breakpoints>
19+
</Bucket>

Project 03 - PlayLocalVideo/PlayLocalVideo/Base.lproj/Main.storyboard

+4-7
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@
4444
<color key="separatorColor" red="0.054901960780000002" green="0.054901960780000002" blue="0.058823529409999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4545
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
4646
<prototypes>
47-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="VideoCell" rowHeight="221" id="cTg-1W-c1p" customClass="VideoCell" customModule="PlayLocalVideo" customModuleProvider="target">
48-
<rect key="frame" x="0.0" y="28" width="375" height="221"/>
47+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="VideoCell" rowHeight="220" id="cTg-1W-c1p" customClass="VideoCell" customModule="PlayLocalVideo" customModuleProvider="target">
48+
<rect key="frame" x="0.0" y="28" width="375" height="220"/>
4949
<autoresizingMask key="autoresizingMask"/>
5050
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cTg-1W-c1p" id="dl3-Uc-PdB">
51-
<rect key="frame" x="0.0" y="0.0" width="375" height="221"/>
51+
<rect key="frame" x="0.0" y="0.0" width="375" height="219"/>
5252
<autoresizingMask key="autoresizingMask"/>
5353
<subviews>
5454
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="videoScreenshot01" translatesAutoresizingMaskIntoConstraints="NO" id="6U4-9Y-a9S">
5555
<rect key="frame" x="0.0" y="0.0" width="375" height="220"/>
56-
<constraints>
57-
<constraint firstAttribute="height" constant="220" id="KPc-1H-1GT"/>
58-
</constraints>
5956
</imageView>
6057
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="r3v-qy-767">
6158
<rect key="frame" x="157.5" y="80.5" width="60" height="60"/>
@@ -70,7 +67,7 @@
7067
</subviews>
7168
</stackView>
7269
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="7G0-fE-fb0">
73-
<rect key="frame" x="128" y="165" width="119" height="43.5"/>
70+
<rect key="frame" x="128" y="164" width="119" height="43.5"/>
7471
<subviews>
7572
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Emoji Among Us" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tDB-Aj-ZcJ">
7673
<rect key="frame" x="0.0" y="0.0" width="119" height="19.5"/>

Project 03 - PlayLocalVideo/PlayLocalVideo/VideoCell.swift

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
import UIKit
1010

11+
struct Video {
12+
let image: String
13+
let title: String
14+
let source: String
15+
}
16+
1117
class VideoCell: UITableViewCell {
1218

1319
@IBOutlet weak var videoScreenshot: UIImageView!
@@ -19,11 +25,10 @@ class VideoCell: UITableViewCell {
1925
// Initialization code
2026
}
2127

22-
public func bindDataSource(with dataSource: VideoCellDataSource) {
23-
let videoModel = dataSource.videoCellModel
24-
videoScreenshot.image = UIImage(named: videoModel.videoScreenShotImageName)
25-
videoTitleLabel.text = videoModel.videoTitle
26-
videoSourceLabel.text = videoModel.videoSourceSubTitle
28+
public func bind(video: Video) {
29+
videoScreenshot.image = UIImage(named: video.image)
30+
videoTitleLabel.text = video.title
31+
videoSourceLabel.text = video.source
2732
}
2833

2934
override func setSelected(_ selected: Bool, animated: Bool) {

Project 03 - PlayLocalVideo/PlayLocalVideo/VideoCellDataSource.swift

-33
This file was deleted.

Project 03 - PlayLocalVideo/PlayLocalVideo/VideoModel.swift

-15
This file was deleted.

Project 03 - PlayLocalVideo/PlayLocalVideo/ViewController.swift

+15-19
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,30 @@ import UIKit
1010
import AVKit
1111
import AVFoundation
1212

13-
private struct Constant {
14-
static let videoPath = Bundle.main.path(forResource: "emoji zone", ofType: "mp4")
15-
}
16-
1713
class ViewController: UIViewController {
1814

1915
@IBOutlet weak var tableView: UITableView!
20-
var videoDataSource = [VideoCellDataSource]()
16+
17+
let data = [
18+
Video(image: "videoScreenshot01", title: "Introduce 3DS Mario", source: "Youtube - 06:32"),
19+
Video(image: "videoScreenshot02", title: "Emoji Among Us", source: "Vimeo - 3:34"),
20+
Video(image: "videoScreenshot03", title: "Seals Documentary", source: "Vine - 00:06"),
21+
Video(image: "videoScreenshot04", title: "Adventure Time", source: "Youtube - 02:39"),
22+
Video(image: "videoScreenshot05", title: "Facebook HQ", source: "Facebook - 10:20"),
23+
Video(image: "videoScreenshot06", title: "Lijiang Lugu Lake", source: "Allen - 20:30")
24+
]
2125

2226
override func viewDidLoad() {
2327
super.viewDidLoad()
24-
self.videoDataSource = VideoCellDataSource.constructDataSource()
28+
tableView.rowHeight = 220
2529
}
2630

2731
@IBAction func playVideoButtonDidTouch(_ sender: Any) {
28-
if let path = Constant.videoPath, let url = URL(string: path) {
32+
if let path = Bundle.main.path(forResource: "emoji zone", ofType: "mp4") {
2933
let playViewController = AVPlayerViewController()
30-
let playerView = AVPlayer(url: url)
34+
let playerView = AVPlayer(url: URL(fileURLWithPath: path))
3135
playViewController.player = playerView
32-
self.present(playViewController, animated: true) {
36+
present(playViewController, animated: true) {
3337
playViewController.player?.play()
3438
}
3539
}
@@ -46,21 +50,13 @@ extension ViewController: UITableViewDataSource {
4650
}
4751

4852
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
49-
return self.videoDataSource.count
53+
return data.count
5054
}
5155

5256
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
5357
let cell = tableView.dequeueReusableCell(withIdentifier: "VideoCell", for: indexPath) as! VideoCell
54-
let dataSource = self.videoDataSource[indexPath.row]
55-
cell.bindDataSource(with: dataSource)
58+
cell.bind(video: data[indexPath.row])
5659
return cell
5760
}
5861
}
5962

60-
extension ViewController: UITableViewDelegate {
61-
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
62-
let dataSource = self.videoDataSource[indexPath.row]
63-
return dataSource.cellHeight
64-
}
65-
}
66-

0 commit comments

Comments
 (0)