I tried with viewWillLayoutSubviews: at first, but it caused a recursive call which lead to EXCBADACCESS, so I fought viewDidLoad: might be more appropriate.
I've added a boolean to check whether the properties have been set in viewWillLayoutSubviews:, and although it's not that elegant, it works as expected.
Thank you very much for your help.
Post
Replies
Boosts
Views
Activity
Sorry, I meant what is the recommended way to initially set these properties, as viewWillTransition(to size:, with coordinator:) only gets called when there is a size change, not initially? I'm thinking about setting them initially in viewDidLoad:, but does the size provided by viewWillTransition(to size:, with coordinator:) is always equals to view.bounds.size?
Thanks.
Thank you.
I've added a function that takes the size as its input to update the split view controller properties, like this:
private func updatePreferredBehavior(for size: CGSize) {
if size.width >= 1194 {
preferredDisplayMode = .twoBesideSecondary
preferredSplitBehavior = .tile
}
else {
preferredDisplayMode = .automatic
preferredSplitBehavior = .automatic
}
}
What is the recommended event to call such a method though? Should I call it in viewDidLoad: with the view.bounds.size or is there a better way?
Thanks.