Post

Replies

Boosts

Views

Activity

NavigationSplitView 2-column loses state when minimized on iPad
Hello! I've noticed that when I am using NavigationSplitView and I minimize the app on iPadOS and then resume, if I am using a 2 column setup it loses state upon resume. This does not appear to happen on with a 3 column setup though. I'm wondering if others have run into this and if anyone has figured out a way around it. It seems like it's a bug and I should file a bug for it, but wanted to check with more people first. Here's some example code, run it, select your number of columns, then minimize the app, count to 3 (because why not!) and open the app and you'll notice that $selection is now nil. import SwiftUI struct Item: Identifiable, Hashable {   var id: Int   var name: String   var description: String } struct ContentView: View {   @State var selection: Item?   var items: [Item] = [     .init(id: 1, name: "One", description: "Is the loneliest number"),     .init(id: 2, name: "Two", description: "Two can be as bad as one"),     .init(id: 3, name: "Three", description: "Three Dog Night")   ]   var body: some View {     TabView {       NavigationSplitView {         List(items, selection: $selection) { item in           NavigationLink(value: item) {             Text(item.name)           }         }       } content: {         if let selection {           Text(selection.name).font(.title)           Text(selection.description)         } else {           EmptyView()         }       } detail: {         VStack {           Text("Detail here")         }       }       .tabItem {         Label("3 Columns", systemImage: "rectangle.split.3x1")       }       NavigationSplitView {         List(items, selection: $selection) { item in           NavigationLink(value: item) {             Text(item.name)           }         }       } detail: {         if let selection {           Text(selection.name).font(.title)           Text(selection.description)         } else {           EmptyView()         }       }       .tabItem {         Label("2 Columns", systemImage: "rectangle.split.2x1")       }     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
1
2
623
Feb ’23
Reference photo from picker, rather than copy?
Hello, is it possible to reference a photo from the photo picker (either UIKit or SwiftUI), such that I do not need to copy it somewhere else? Currently, I am storing the copy in CoreData in a field with external storage, but it did cross my mind that I don't actually need a copy in my own storage if I could point back to the photo library. If the user deleted the photo from the library that would be fine.
1
0
515
Aug ’23