Post

Replies

Boosts

Views

Activity

SwiftUI navigation broken in Xcode 12.5
Yesterday I managed to create a SwiftUI navigation that was deselecting List row when returning from the subview. Today I updated Xcode to 12.5 and my row deselection code is not is not working any more. So here is in it's simplest form, code that yesterday was deselecting row in the List after I returned back from the subview. When MostPopularView is disappearing it updates selectedArticle @State property to nil and that's all. Any ideas why it's broken now? I couldn't find any updates in release notes regarding this. swift struct MostPopularView: View {     @State private var selectedArticle: MostPopularArticle?     var body: some View {         List(mostPopularViewModel.articles, id: \.self, selection: $selectedArticle) { article in             NavigationLink(                 destination: ArticleView(article: article),                 label: {                     ArticleListItem(article: article)                 })         }         .onDisappear(perform: deselectRow)     }     private func deselectRow() {         self.selectedArticle = nil     } }
1
0
885
Apr ’21
How to refresh AsyncImage
I'm really amazed of the new AsyncImage view that is now available in iOS 15. I'm currently exploring it and implemented a simple view that just loads a random image from API. But then I wanted to create that I can just refresh this AsyncImage view on the button tap or whatever, but I have no idea how to do it as in this case URL doesn't change I just need to refresh view itself. I saw that there is .refreshable modifier added in iOS 15 that marks View as refreshable. I don't know how to use it.. Any ideas how to reload this AsyncImage view? AsyncImage(url: url, scale: 1) { image in image .resizable() .aspectRatio(1, contentMode: .fit) .frame(width: 300, height: 400, alignment: .center) } placeholder: { ProgressView() .progressViewStyle(CircularProgressViewStyle(tint: .orange)) .scaleEffect(3) } .refreshable { }
2
0
3.7k
Jun ’21