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

Lines changed: 45 additions & 0 deletions
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

Lines changed: 119 additions & 84 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 2 deletions
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+
}
Lines changed: 6 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)