Shouldn't it be always true for iPhone portrait mode? The answers here: UISplitViewController in portrait on iPhone shows detail VC instead of master don't really solve my problem.
Asked
Active
Viewed 775 times
6
-
1From apple's documentation: "The value of this property is false when the split view controller is capable of displaying both of its child view controllers at the same time, even if it is not showing them both at the moment." – Ramy Al Zuhouri Jun 02 '17 at 21:32
-
1Yeah but on iPhone portrait mode, which is compact, it's not capable to display both master & detail screens right? – yvetterowe Jun 05 '17 at 17:14
-
2In my case the value was false until viewDidLayoutSubviews() was called for the first time. – Klaas Apr 04 '19 at 19:07
3 Answers
0
@Klaas comment is right on. I could only observe the value of isCollapsed
be meaningful after the view is properly laid out and added to the view hierarchy with a proper trait collection.
In my case moving logic that depended on isCollapsed
from viewWillAppear
to viewDidAppear
did the trick.

Rafael Nobre
- 5,062
- 40
- 40
0
For me, isCollapsed
was false
even after viewDidLayoutSubviews()
.
I ended up checking if the view controller's traitCollection.horizontalSizeClass
was equal to .unspecified
, then I know that isCollapsed
is not ready to use yet.
You can then watch for changes on the traitCollection. In my case, I needed to know when horizontalSizeClass
is .regular
, so the following code did it:
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if traitCollection.horizontalSizeClass == .regular {
...
}
}

Cody
- 650
- 9
- 16