Posts

Post marked as solved
7 Replies
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 marked as solved
7 Replies
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.
Post marked as solved
7 Replies
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.
Post marked as solved
6 Replies
According to some developers who talked with SwiftUI engineers, there won't be an equivalent to collection views, at least not yet.However, it's still possible to integrate platform-specific collection views with SwiftUI. Also, there has been huge improvements to collection view data source and layout this year. 🙂
Post marked as solved
6 Replies
You're right.Regarding using PageControl with SwiftUI, there is a tutorial on it (Interfacing with UIKit).However, collection views are such a widely used component accoss all Apple platforms that it would be useful to have it out of the box. I understand it may be much harder to implement than "List", because of how much versatile it can be, but I really hope it will be added in the future.
Post marked as solved
6 Replies
I agree these are not technically "collection views" or "table views".What I meant and would like to achieve is a grid layout (like in Music's album library, Apple Books' library, etc.) or cascading layout (e.g. Pinterest) natively in SwiftUI.According to SwiftUI's documentation, a List is a container that presents rows of data arranged in a single column. What I'm looking for is a container that present data arranged in several columns and rows.