Skip to content

Commit cac788b

Browse files
committed
testing more options in new example, removed old examples, added percolation example
1 parent b9e53ce commit cac788b

File tree

74 files changed

+829
-3945
lines changed

Some content is hidden

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

74 files changed

+829
-3945
lines changed

bk2ch09p490SplitViewControllerNew/SplitViewControllerNew/ViewController.swift

+45
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class ViewController: UIViewController {
4343
}
4444

4545
split.delegate = self
46+
47+
print(split.presentsWithGesture)
48+
split.presentsWithGesture = true // also affects button presence! default is true
49+
print(split.showsSecondaryOnlyButton)
50+
split.showsSecondaryOnlyButton = true // only in three-columns; default is false
4651

4752
delay(2) {
4853
print(split.viewControllers) // NB, no longer encompasses all vcs
@@ -52,6 +57,23 @@ class ViewController: UIViewController {
5257
print(pep.splitViewController as Any)
5358
}
5459
}
60+
var initial = true
61+
override func viewDidLayoutSubviews() {
62+
super.viewDidLayoutSubviews()
63+
if self.initial {
64+
if self.traitCollection.userInterfaceIdiom == .pad {
65+
if self.view.bounds.width < self.view.bounds.height {
66+
let svc = self.children[0] as! UISplitViewController
67+
svc.show(.primary)
68+
}
69+
}
70+
var playTricks: Bool { false }
71+
if playTricks {
72+
self.playThoseTricks()
73+
}
74+
}
75+
self.initial = false
76+
}
5577
}
5678

5779
extension ViewController : UISplitViewControllerDelegate {
@@ -102,6 +124,16 @@ extension ViewController : UISplitViewControllerDelegate {
102124
}
103125
return proposedDisplayMode
104126
}
127+
func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) {
128+
print("will change to", displayMode.rawValue)
129+
}
130+
131+
func splitViewControllerInteractivePresentationGestureWillBegin(_ svc: UISplitViewController) {
132+
print("gesture beginning")
133+
}
134+
func splitViewControllerInteractivePresentationGestureDidEnd(_ svc: UISplitViewController) {
135+
print("gesture ended")
136+
}
105137
}
106138

107139
extension UISplitViewController.Column {
@@ -116,3 +148,16 @@ extension UISplitViewController.Column {
116148
// suppose Moe is showing in split, we unsplit: still see moe, that's good, but moe is not selected in primary
117149

118150
// suppose Jack is showing in full, we split to become compact: we collapse to Moe or maybe it's to whatever was showing last time we were compact
151+
152+
extension ViewController {
153+
func playThoseTricks() {
154+
print("tricks")
155+
let svc = self.children[0] as! UISplitViewController
156+
svc.preferredDisplayMode = .oneOverSecondary
157+
svc.maximumPrimaryColumnWidth = 250
158+
// svc.preferredPrimaryColumnWidthFraction = 0.3 // no effect
159+
let reg = UITraitCollection(horizontalSizeClass: .regular)
160+
let traits = UITraitCollection(traitsFrom: [reg])
161+
self.setOverrideTraitCollection(traits, forChild: svc)
162+
}
163+
}

bk2ch09p491SecretRetention/SecretRetention.xcodeproj/project.pbxproj renamed to bk2ch09p490SplitViewControllerPercolation/SplitViewControllerNew.xcodeproj/project.pbxproj

+119-84
Large diffs are not rendered by default.

bk2ch09p491SecretRetention/SecretRetention/AppDelegate.swift renamed to bk2ch09p490SplitViewControllerPercolation/SplitViewControllerNew/AppDelegate.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import UIKit
44

5-
@UIApplicationMain
5+
@main
66
class AppDelegate: UIResponder, UIApplicationDelegate {
77

8-
var window: UIWindow?
98

109

1110
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1211
// Override point for customization after application launch.
1312
return true
1413
}
1514

15+
16+
1617
}
1718

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "jack.jpg",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "manny.jpg",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "moe.jpg",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}

bk2ch09p491SecretRetention/SecretRetention/Base.lproj/LaunchScreen.storyboard renamed to bk2ch09p490SplitViewControllerPercolation/SplitViewControllerNew/Base.lproj/LaunchScreen.storyboard

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
1414
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1515
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
1717
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
1818
</view>
1919
</viewController>
+6-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14092" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_0" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
63
<dependencies>
7-
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14081.1"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
95
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
106
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
117
</dependencies>
128
<scenes>
139
<!--View Controller-->
1410
<scene sceneID="tne-QT-ifu">
1511
<objects>
16-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="SplitViewControllerManual" customModuleProvider="target" sceneMemberID="viewController">
12+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
1713
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
18-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1915
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
21-
<viewLayoutGuide key="safeArea" id="iru-0R-cwp"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
2218
</view>
2319
</viewController>
2420
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
import UIKit
3+
4+
class Pep: UIViewController {
5+
6+
let boy : String
7+
@IBOutlet var name : UILabel!
8+
@IBOutlet var pic : UIImageView!
9+
10+
override var nibName: String? { "Pep" }
11+
12+
init(pepBoy boy:String) {
13+
self.boy = boy
14+
super.init(nibName: nil, bundle: nil)
15+
}
16+
17+
convenience init() {
18+
self.init(pepBoy: "Manny")
19+
}
20+
21+
required init(coder: NSCoder) {
22+
fatalError("NSCoding not supported")
23+
}
24+
25+
override func viewDidLoad() {
26+
super.viewDidLoad()
27+
self.name.text = self.boy
28+
self.pic.image = UIImage(named:self.boy.lowercased())
29+
let bbi = UIBarButtonItem(
30+
image: UIImage(systemName: "paperclip"),
31+
primaryAction: UIAction(title: "") {
32+
_ in print("does nothing")
33+
}
34+
)
35+
self.navigationItem.rightBarButtonItem = bbi
36+
}
37+
38+
@IBAction func doShowHide(_ sender: Any) {
39+
self.showHide(self)
40+
// also looking to see whether split view controller can still respond to `show:sender:`
41+
let vc = UIViewController()
42+
vc.view.backgroundColor = .blue
43+
self.splitViewController?.show(vc, sender: self)
44+
// well, it didn't like that! it took it as "show compact column" and turned it into presentation
45+
}
46+
47+
override var description : String {
48+
return self.boy
49+
}
50+
51+
// =======
52+
53+
override func targetViewController(forAction action: Selector, sender: Any?) -> UIViewController? {
54+
print(self, #function, action, "called")
55+
let result = super.targetViewController(forAction: action, sender: sender)
56+
print(self, #function, result as Any)
57+
return result
58+
}
59+
60+
}

0 commit comments

Comments
 (0)