Post

Replies

Boosts

Views

Activity

Reply to List sections empty after adding .id()
Although @snuff4's answer solved the empty cells issue in my real project, scrolling to desired cell/row wasn't working when using ScrollViewReader's scrollTo method. I have come up with a weird fix that works for me. It is weird because I don't know how and why it works, but it works. If anyone can explain why it works, I'll be very thankful. The solution is, I created a new ViewModifier named EmbedInSection that just embeds the content in Section. struct EmbedInSection: ViewModifier { func body(content: Content) -> some View { Section { content } } } And I used it like: var body: some View { List { ForEach(intervals) { interval in Text(interval.name) .id(interval.id) .modifier(EmbedInSection()) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’22
Reply to Playlist's curatorName property always returns nil.
@JoeKun, I should have provided these details when asking the question. Sorry about that. I am using iOS 15 beta 3. Here's the code I am using to fetch library playlists: var playlists: [Playlist] struct MyPlaylistsResponse: Decodable { let data: [Playlist] } let url = URL(string: "https://api.music.apple.com/v1/me/library/playlists")! let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url)) do { let dataResponse = try await dataRequest.response() let decoder = JSONDecoder() let playlistsResponse = try decoder.decode(MyPlaylistsResponse.self, from: dataResponse.data) playlists = playlistsResponse.data } catch let error { print("** Error **") print(error) } and then I am trying to get the curator name like this: for playlist in playlists { print(playlist.curatorName) } playlist.curatorName returns nil for all playlists in array.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to iOS Widget - Trim not drawing
Have you tried running it on a real device rather than Simulator or SwiftUI Preview? I had a similar problem, not with trim, but with opacity Any opacity value less than 1.0 hides the view in Simulator and SwiftUI Preview. But it worked fine on real device.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21