@@ -43,6 +43,11 @@ class ViewController: UIViewController {
43
43
}
44
44
45
45
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
46
51
47
52
delay ( 2 ) {
48
53
print ( split. viewControllers) // NB, no longer encompasses all vcs
@@ -52,6 +57,23 @@ class ViewController: UIViewController {
52
57
print ( pep. splitViewController as Any )
53
58
}
54
59
}
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
+ }
55
77
}
56
78
57
79
extension ViewController : UISplitViewControllerDelegate {
@@ -102,6 +124,16 @@ extension ViewController : UISplitViewControllerDelegate {
102
124
}
103
125
return proposedDisplayMode
104
126
}
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
+ }
105
137
}
106
138
107
139
extension UISplitViewController . Column {
@@ -116,3 +148,16 @@ extension UISplitViewController.Column {
116
148
// suppose Moe is showing in split, we unsplit: still see moe, that's good, but moe is not selected in primary
117
149
118
150
// 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
+ }
0 commit comments