Post

Replies

Boosts

Views

Created

Saving Live Photos to CoreData in SwiftUI
I currently have an app that allows users to import photos, the photos are then stored in CoreData as Binary Data and then synced with iCloud. When a user wants to view the photo, I display the photo to them with Image(uiImage: UIImage(data: savedImageData)). I would like to allow users to upload live photos to the application as well, and have them saved into CoreData. I have tried searching online but haven't found a concrete process to do this. So how does one save Live Photos into CoreData? P.S. I am saving the photos from a UIImagePickerController wrapped as UIViewControllerRepresentable to input my images currently, if something else is required to get the Live Photo component as well I am open to suggestions.
1
0
1k
Oct ’20
Context Menu Destructive Actions, SwiftUI
I'm trying to add a delete action in a context menu, however it just gets displayed as the default black color. The Photos app uses a red color for its delete action as well. I've seen in some spaces online that this is not a functionality currently provided of contextMenu, however I have also seen it used in third party apps in the wild from developers such as Steve Troughton-Smith in his Broadcast app (It's not letting me link to his tweet, however he has a video showing a red item in a context menu). Does anyone know how to accomplish this? Also, looking on Apple's documentation - https://developer.apple.com/documentation/swiftui/contextmenu for contextMenu it says that they have been deprecated for everything except for macOS. I find it strange that they deprecated it just one year after introducing it. Was this replaced by another component that I should be using? var body: some View { 				ScrollView { 						LazyVGrid(columns: columns, spacing: 20) { 								ForEach(photos) { photo in 										Image(uiImage: UIImage(data: photo.imageData!)!) 												.resizable() 												.aspectRatio(1, contentMode: .fill) 												.contextMenu(menuItems: { 														Button(action: { 																deletePhoto(selectedPhoto: photo) 														}) { 																Label("Remove", systemImage: "trash") 														} 												}) 								} 						} 						.padding() 						.navigationBarTitle(Text("Albums")) 						.navigationBarItems(trailing: 								Button(action: { 										self.showingImagePicker = true 								}) { 										Image(systemName: "plus.circle.fill") 								} 						) 						.sheet(isPresented: $showingImagePicker, onDismiss: loadImage) { 								ImagePicker(image: self.$inputImage) 						} 				} 		}
7
0
4.5k
Oct ’20
Saving Live Photos to CoreData in SwiftUI
I currently have an app that allows users to import photos, the photos are then stored in CoreData as Binary Data and then synced with iCloud. When a user wants to view the photo, I display the photo to them with Image(uiImage: UIImage(data: savedImageData)). I would like to allow users to upload live photos to the application as well, and have them saved into CoreData. I have tried searching online but haven't found a concrete process to do this. So how does one save Live Photos into CoreData? P.S. I am saving the photos from a UIImagePickerController wrapped as UIViewControllerRepresentable to input my images currently, if something else is required to get the Live Photo component as well I am open to suggestions.
Replies
1
Boosts
0
Views
1k
Activity
Oct ’20
Context Menu Destructive Actions, SwiftUI
I'm trying to add a delete action in a context menu, however it just gets displayed as the default black color. The Photos app uses a red color for its delete action as well. I've seen in some spaces online that this is not a functionality currently provided of contextMenu, however I have also seen it used in third party apps in the wild from developers such as Steve Troughton-Smith in his Broadcast app (It's not letting me link to his tweet, however he has a video showing a red item in a context menu). Does anyone know how to accomplish this? Also, looking on Apple's documentation - https://developer.apple.com/documentation/swiftui/contextmenu for contextMenu it says that they have been deprecated for everything except for macOS. I find it strange that they deprecated it just one year after introducing it. Was this replaced by another component that I should be using? var body: some View { 				ScrollView { 						LazyVGrid(columns: columns, spacing: 20) { 								ForEach(photos) { photo in 										Image(uiImage: UIImage(data: photo.imageData!)!) 												.resizable() 												.aspectRatio(1, contentMode: .fill) 												.contextMenu(menuItems: { 														Button(action: { 																deletePhoto(selectedPhoto: photo) 														}) { 																Label("Remove", systemImage: "trash") 														} 												}) 								} 						} 						.padding() 						.navigationBarTitle(Text("Albums")) 						.navigationBarItems(trailing: 								Button(action: { 										self.showingImagePicker = true 								}) { 										Image(systemName: "plus.circle.fill") 								} 						) 						.sheet(isPresented: $showingImagePicker, onDismiss: loadImage) { 								ImagePicker(image: self.$inputImage) 						} 				} 		}
Replies
7
Boosts
0
Views
4.5k
Activity
Oct ’20