Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit e18889c

Browse files
author
Mitsuyoshi Yamazaki
committed
Replace scrollable content views
1 parent abac0fd commit e18889c

File tree

8 files changed

+161
-57
lines changed

8 files changed

+161
-57
lines changed

ScrollableTabController.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
EDEA2CC71F2F18BB00B35F4A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDEA2CC51F2F18BB00B35F4A /* LaunchScreen.storyboard */; };
2121
EDEA2CCD1F2F309900B35F4A /* ScrollableTabController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED747CFA1F2B356800E228D2 /* ScrollableTabController.framework */; };
2222
EDEA2CCE1F2F309900B35F4A /* ScrollableTabController.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = ED747CFA1F2B356800E228D2 /* ScrollableTabController.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
23+
EDFE04241F4553BA00EDA902 /* TimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDFE04231F4553BA00EDA902 /* TimelineViewController.swift */; };
2324
/* End PBXBuildFile section */
2425

2526
/* Begin PBXContainerItemProxy section */
@@ -64,6 +65,7 @@
6465
EDEA2CC31F2F18BB00B35F4A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6566
EDEA2CC61F2F18BB00B35F4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
6667
EDEA2CC81F2F18BB00B35F4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
68+
EDFE04231F4553BA00EDA902 /* TimelineViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimelineViewController.swift; sourceTree = "<group>"; };
6769
/* End PBXFileReference section */
6870

6971
/* Begin PBXFrameworksBuildPhase section */
@@ -132,6 +134,7 @@
132134
children = (
133135
EDEA2CBC1F2F18BB00B35F4A /* AppDelegate.swift */,
134136
EDABFDFD1F44299000E1D56C /* ProfileViewController.swift */,
137+
EDFE04231F4553BA00EDA902 /* TimelineViewController.swift */,
135138
EDEA2CC01F2F18BB00B35F4A /* Main.storyboard */,
136139
EDEA2CC31F2F18BB00B35F4A /* Assets.xcassets */,
137140
EDEA2CC51F2F18BB00B35F4A /* LaunchScreen.storyboard */,
@@ -288,6 +291,7 @@
288291
files = (
289292
EDABFDFE1F44299000E1D56C /* ProfileViewController.swift in Sources */,
290293
EDEA2CBD1F2F18BB00B35F4A /* AppDelegate.swift in Sources */,
294+
EDFE04241F4553BA00EDA902 /* TimelineViewController.swift in Sources */,
291295
);
292296
runOnlyForDeploymentPostprocessing = 0;
293297
};

ScrollableTabControllerDemo/AppDelegate.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
var window: UIWindow?
1616

17-
func application(_ application: UIApplication,
18-
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1918

2019
window = UIWindow(frame: UIScreen.main.bounds)
2120

2221
let scrollableTabController = ScrollableTabController()
2322

2423
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
25-
let demoTableViewController1 = storyboard.instantiateViewController(withIdentifier: "DemoTableViewController") as! UITableViewController
26-
let demoTableViewController2 = storyboard.instantiateViewController(withIdentifier: "DemoTableViewController") as! UITableViewController
27-
28-
demoTableViewController1.title = "TableView 1"
29-
demoTableViewController2.title = "TableView 2"
24+
let timelineViewController = storyboard.instantiateViewController(withIdentifier: "TimelineViewController") as! TimelineViewController
25+
timelineViewController.title = "Timeline"
26+
timelineViewController.cellIdentifier = .normal
3027

31-
demoTableViewController2.tableView.backgroundColor = UIColor.white
28+
let imageTimelineViewController = storyboard.instantiateViewController(withIdentifier: "TimelineViewController") as! TimelineViewController
29+
imageTimelineViewController.title = "Media"
30+
imageTimelineViewController.cellIdentifier = .image
3231

3332
let upperContentViewController = storyboard.instantiateViewController(withIdentifier: "ProfileViewController")
3433

35-
scrollableTabController.viewControllers = [ demoTableViewController1, demoTableViewController2 ]
34+
scrollableTabController.viewControllers = [ timelineViewController, imageTimelineViewController ]
3635
scrollableTabController.upperContentViewController = upperContentViewController
3736

3837
let navigationController = UINavigationController.init(rootViewController: scrollableTabController)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"scale" : "2x"
10+
},
11+
{
12+
"idiom" : "universal",
13+
"filename" : "Dummy [email protected]",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"scale" : "2x"
10+
},
11+
{
12+
"idiom" : "universal",
13+
"filename" : "Dummy Image [email protected]",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading

ScrollableTabControllerDemo/Base.lproj/Main.storyboard

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -246,53 +246,6 @@
246246
</objects>
247247
<point key="canvasLocation" x="179" y="171"/>
248248
</scene>
249-
<!--Title-->
250-
<scene sceneID="oJP-pu-pmD">
251-
<objects>
252-
<viewController storyboardIdentifier="UpperContentViewController" title="Title" id="ZzW-fN-vr1" sceneMemberID="viewController">
253-
<layoutGuides>
254-
<viewControllerLayoutGuide type="top" id="asA-Pe-LIf"/>
255-
<viewControllerLayoutGuide type="bottom" id="Abw-Ki-QLt"/>
256-
</layoutGuides>
257-
<view key="view" contentMode="scaleToFill" id="ISP-h2-KeP" customClass="TouchTransparentView" customModule="ScrollableTabController">
258-
<rect key="frame" x="0.0" y="0.0" width="375" height="200"/>
259-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
260-
<subviews>
261-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TBc-eK-3Ka">
262-
<rect key="frame" x="0.0" y="0.0" width="375" height="142"/>
263-
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
264-
<constraints>
265-
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="142" id="XgP-xy-lg9"/>
266-
</constraints>
267-
</view>
268-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xma-fV-DOJ">
269-
<rect key="frame" x="166" y="159" width="44" height="21"/>
270-
<constraints>
271-
<constraint firstAttribute="height" constant="21" id="SlB-Ui-8ww"/>
272-
</constraints>
273-
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
274-
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
275-
<nil key="highlightedColor"/>
276-
</label>
277-
</subviews>
278-
<color key="backgroundColor" red="1" green="0.2411553136" blue="0.24570151730000001" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
279-
<constraints>
280-
<constraint firstItem="Xma-fV-DOJ" firstAttribute="centerX" secondItem="ISP-h2-KeP" secondAttribute="centerX" id="I0o-0v-8ew"/>
281-
<constraint firstAttribute="trailing" secondItem="TBc-eK-3Ka" secondAttribute="trailing" id="biQ-5w-4xg"/>
282-
<constraint firstItem="Xma-fV-DOJ" firstAttribute="top" secondItem="TBc-eK-3Ka" secondAttribute="bottom" constant="17" id="j15-ZI-9Ic"/>
283-
<constraint firstItem="TBc-eK-3Ka" firstAttribute="leading" secondItem="ISP-h2-KeP" secondAttribute="leading" id="lDW-u7-pch"/>
284-
<constraint firstItem="TBc-eK-3Ka" firstAttribute="top" secondItem="asA-Pe-LIf" secondAttribute="bottom" id="sCt-io-ch6"/>
285-
<constraint firstItem="Abw-Ki-QLt" firstAttribute="top" secondItem="Xma-fV-DOJ" secondAttribute="bottom" constant="20" id="w7e-R5-SU4"/>
286-
</constraints>
287-
</view>
288-
<nil key="simulatedStatusBarMetrics"/>
289-
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
290-
<size key="freeformSize" width="375" height="200"/>
291-
</viewController>
292-
<placeholder placeholderIdentifier="IBFirstResponder" id="JgZ-IY-9oM" userLabel="First Responder" sceneMemberID="firstResponder"/>
293-
</objects>
294-
<point key="canvasLocation" x="1012" y="-40.479760119940032"/>
295-
</scene>
296249
<!--Profile View Controller-->
297250
<scene sceneID="ymz-hx-sqa">
298251
<objects>
@@ -375,12 +328,75 @@
375328
</viewController>
376329
<placeholder placeholderIdentifier="IBFirstResponder" id="h0U-ZZ-BQp" userLabel="First Responder" sceneMemberID="firstResponder"/>
377330
</objects>
378-
<point key="canvasLocation" x="1761.5942028985507" y="3.2608695652173916"/>
331+
<point key="canvasLocation" x="979" y="-21"/>
332+
</scene>
333+
<!--Timeline View Controller-->
334+
<scene sceneID="gk7-d5-THM">
335+
<objects>
336+
<tableViewController storyboardIdentifier="TimelineViewController" id="ZkN-Hf-ay5" customClass="TimelineViewController" customModule="ScrollableTabControllerDemo" customModuleProvider="target" sceneMemberID="viewController">
337+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Cgz-nI-gjF">
338+
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
339+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
340+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
341+
<prototypes>
342+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="Cell" rowHeight="108" id="hlr-6b-xth">
343+
<rect key="frame" x="0.0" y="28" width="414" height="108"/>
344+
<autoresizingMask key="autoresizingMask"/>
345+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hlr-6b-xth" id="bfA-Od-bsn">
346+
<rect key="frame" x="0.0" y="0.0" width="414" height="107"/>
347+
<autoresizingMask key="autoresizingMask"/>
348+
<subviews>
349+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Cell" translatesAutoresizingMaskIntoConstraints="NO" id="YNP-fj-kW0">
350+
<rect key="frame" x="0.0" y="0.0" width="414" height="107"/>
351+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
352+
</imageView>
353+
</subviews>
354+
<constraints>
355+
<constraint firstAttribute="trailing" secondItem="YNP-fj-kW0" secondAttribute="trailing" id="86G-Fj-T7x"/>
356+
<constraint firstItem="YNP-fj-kW0" firstAttribute="top" secondItem="bfA-Od-bsn" secondAttribute="top" id="9vE-aX-5v4"/>
357+
<constraint firstItem="YNP-fj-kW0" firstAttribute="leading" secondItem="bfA-Od-bsn" secondAttribute="leading" id="Uuo-YP-cFc"/>
358+
<constraint firstAttribute="bottom" secondItem="YNP-fj-kW0" secondAttribute="bottom" id="d1a-W4-eAW"/>
359+
</constraints>
360+
</tableViewCellContentView>
361+
</tableViewCell>
362+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ImageCell" rowHeight="292" id="jUv-eq-Dl3">
363+
<rect key="frame" x="0.0" y="136" width="414" height="292"/>
364+
<autoresizingMask key="autoresizingMask"/>
365+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jUv-eq-Dl3" id="Dal-Am-Hh4">
366+
<rect key="frame" x="0.0" y="0.0" width="414" height="291"/>
367+
<autoresizingMask key="autoresizingMask"/>
368+
<subviews>
369+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ImageCell" translatesAutoresizingMaskIntoConstraints="NO" id="JeJ-zS-ROH">
370+
<rect key="frame" x="0.0" y="0.0" width="414" height="291"/>
371+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
372+
</imageView>
373+
</subviews>
374+
<constraints>
375+
<constraint firstItem="JeJ-zS-ROH" firstAttribute="leading" secondItem="Dal-Am-Hh4" secondAttribute="leading" id="8pI-cE-bP6"/>
376+
<constraint firstItem="JeJ-zS-ROH" firstAttribute="top" secondItem="Dal-Am-Hh4" secondAttribute="top" id="L62-rk-xdk"/>
377+
<constraint firstAttribute="trailing" secondItem="JeJ-zS-ROH" secondAttribute="trailing" id="tqq-Cu-kl1"/>
378+
<constraint firstAttribute="bottom" secondItem="JeJ-zS-ROH" secondAttribute="bottom" id="w1F-PO-IQa"/>
379+
</constraints>
380+
</tableViewCellContentView>
381+
</tableViewCell>
382+
</prototypes>
383+
<sections/>
384+
<connections>
385+
<outlet property="dataSource" destination="ZkN-Hf-ay5" id="EzV-fS-RFp"/>
386+
<outlet property="delegate" destination="ZkN-Hf-ay5" id="hId-ym-P3A"/>
387+
</connections>
388+
</tableView>
389+
</tableViewController>
390+
<placeholder placeholderIdentifier="IBFirstResponder" id="CJc-rk-rHp" userLabel="First Responder" sceneMemberID="firstResponder"/>
391+
</objects>
392+
<point key="canvasLocation" x="1711.5942028985507" y="169.56521739130437"/>
379393
</scene>
380394
</scenes>
381395
<resources>
382396
<image name="Button" width="33" height="33"/>
397+
<image name="Cell" width="750" height="197"/>
383398
<image name="CoverImage" width="375" height="125"/>
399+
<image name="ImageCell" width="750" height="518"/>
384400
<image name="PlaceholderText" width="750" height="268"/>
385401
</resources>
386402
</document>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// TimelineViewController.swift
3+
// ScrollableTabController
4+
//
5+
// Created by mitsuyoshi.yamazaki on 2017/08/17.
6+
// Copyright © 2017年 Mitsuyoshi Yamazaki and Speee, Inc. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class TimelineViewController: UITableViewController {
12+
enum CellIdentifier: String {
13+
case normal = "Cell"
14+
case image = "ImageCell"
15+
}
16+
17+
var cellIdentifier = CellIdentifier.normal
18+
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
21+
22+
switch cellIdentifier {
23+
case .normal:
24+
tableView.rowHeight = 108.0 / 375.0 * view.frame.width
25+
case .image:
26+
tableView.rowHeight = 286.0 / 375.0 * view.frame.width
27+
}
28+
}
29+
30+
// MARK: - Table view data source
31+
override func numberOfSections(in tableView: UITableView) -> Int {
32+
return 1
33+
}
34+
35+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
36+
return 20
37+
}
38+
39+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
40+
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier.rawValue, for: indexPath)
41+
return cell
42+
}
43+
}

0 commit comments

Comments
 (0)