Post

Replies

Boosts

Views

Activity

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
3.6k
Oct ’20
CoreData Unrecognized Selector Sent to Instance
I'm trying to add CoreData to my application. This application is going to be a photo application, and give the user the ability to store photos in albums. I have two Entities in CoreData currently, Photo and Album. The Album entity has four attributes. albumCoverImageData: Binary Data, id: UUID, name: String, passwordProtected: Boolean. In addition to these attributes, it has a relationship photos destination Photo Inverse Album. The Photo Entity has two attributes, id: UUID and imageData: BinaryData When trying to add a new album to the database, upon trying to save the context, the application crashes with the following error. 2020-10-20 15:49:33.889808-0400 LockIt[902:92475] -[__NSConcreteUUID compare:]: unrecognized selector sent to instance 0x2817b4fe0 2020-10-20 15:53:28.604954-0400 LockIt[902:92475] [error] error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[__NSConcreteUUID compare:]: unrecognized selector sent to instance 0x2817b4fe0 with userInfo (null) CoreData: error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[__NSConcreteUUID compare:]: unrecognized selector sent to instance 0x2817b4fe0 with userInfo (null) 2020-10-20 15:53:28.622315-0400 LockIt[902:92475] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSConcreteUUID compare:]: unrecognized selector sent to instance 0x2817b4fe0' First throw call stack: (0x1937c65ac 0x1a78b442c 0x1936d0a2c 0x1937c9130 0x1937cb420 0x194b18c90 0x1998e5dc8 0x1998e58a0 0x1998e6ad0 0x1998e77b4 0x19989a410 0x199767b64 0x1998e7100 0x193725764 0x193725718 0x193724cd4 0x1937246a0 0x1949bc5f4 0x199892118 0x1998a0c50 0x199892fc0 0x199761aa0 0x104503bd8 0x104502e68 0x104502854 0x199fd2c04 0x19a2c3ec0 0x19a049990 0x19a0499b8 0x19a049990 0x19a03a1dc 0x19a088444 0x19a4d8f58 0x19a4d71a4 0x19a4d7d78 0x195c4d334 0x196177a4c 0x195c43350 0x195c43030 0x19612ef80 0x196108bc0 0x196190118 0x196193070 0x19618a5f4 0x19374381c 0x193743718 0x193742a28 0x19373cd20 0x19373c4bc 0x1aa24e820 0x1960e9164 0x1960ee840 0x1044f2178 0x193403e40) libc++abi.dylib: terminating with uncaught exception of type NSException ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSConcreteUUID compare:]: unrecognized selector sent to instance 0x2817b4fe0' terminating with uncaught exception of type NSException I have attached relevant Files below. Photo+CoreDataProperties.swift - https://developer.apple.com/forums/content/attachment/220af214-2df8-4d93-9e24-33aff58fd645 Album+CoreDataProperties.swift - https://developer.apple.com/forums/content/attachment/42ba81b9-e024-4146-8b86-2d8bea6c374d AlbumCollectionView.swift - https://developer.apple.com/forums/content/attachment/5bca44b9-7e25-403f-9e8f-58509cc6a2bc I'm at a loss as to what could be going on here, appreciate any insight! Edit: It seems like the formatting is strange with the files I posted, so I also have this StackOverflow post where the word limit let me post everything here - https://stackoverflow.com/questions/64452619/coredata-unrecognized-selector-sent-to-instance.
8
0
5.4k
Oct ’20
Force SwiftUI Navigation Bar to be opaque
I have a view inside of a navigation bar that I am using as a photo preview. I'd like to mimic the Photo's app behavior, and have the image extend past the navigation bar, with the contents blurred by the navigation bar in the background. If you'd like to see an example of what I'm looking to replicate, open the Photos app and select a photo, the navigation bar covers the content that extends beyond it. However, when I extend the View to disregard the safe areas, the navigation bar is fully transparent, and the photo is not blurred at all. I've noticed on the parent view (LazyVGrid in a ScrollView) when scrolling the view under the navigation bar, the navigation bar has my desired effect. Is there any way to force this behavior when the view in not in a ScrollView? Here is my code for the photo preview view. import SwiftUI struct PhotoDetailView: View { 		var photo: Photo 		@State var isNavbarHidden: Bool = false 		 		var body: some View { 				ZStack { 						Rectangle() 								.frame(minWidth: /*@START_MENU_TOKEN@*/0/*@END_MENU_TOKEN@*/,maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, minHeight: /*@START_MENU_TOKEN@*/0/*@END_MENU_TOKEN@*/,maxHeight: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) 								.edgesIgnoringSafeArea(.all) 								.foregroundColor(isNavbarHidden ? .black : Color(UIColor.systemBackground)) 						Image(data: photo.imageData, placeholder: "No Image") 								.resizable() 								.aspectRatio(contentMode: .fit) 				} 				.edgesIgnoringSafeArea(.all) //				.navigationBarHidden(isNavbarHidden) 				.navigationBarTitle("Test Title", displayMode: .inline) 				.onTapGesture(count: /*@START_MENU_TOKEN@*/1/*@END_MENU_TOKEN@*/, perform: { 						withAnimation { 								isNavbarHidden.toggle() 						} 				}) 		} }
0
0
2.2k
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.
1
0
882
Oct ’20