Posts

Post marked as solved
4 Replies
2.9k Views
Hello, I have a view in SwiftUI that has both a Drag and Magnification Gesture. Before iOS 15 my app worked with both gestures on the same view. This is how they are composed: let dragGesture = DragGesture()             .onChanged { value in                 //self.offset = value.translation                 self.currentPosition = CGSize(width: value.translation.width + self.newPosition.width, height: value.translation.height + self.newPosition.height)         }         .onEnded { value in             withAnimation {                 self.currentPosition = CGSize(width: value.translation.width + self.newPosition.width, height: value.translation.height + self.newPosition.height)                 self.newPosition = self.currentPosition                 self.isDragging = false             }         }         let pressGesture = LongPressGesture()             .onEnded { value in                 withAnimation {                     self.isDragging = true                 }         }         let pressGestureDelete = LongPressGesture(minimumDuration: 3)             .onEnded { value in                 self.deleteBtn = true         }         let resizeGesture = MagnificationGesture(minimumScaleDelta: 0.1)             .onChanged { value in                 self.scale *= value             }         .onEnded { value in             self.scale *= value         }                  let combined = pressGesture.sequenced(before: dragGesture).simultaneously(with: pressGestureDelete).simultaneously(with: resizeGesture) And then on my view I am adding the gesture as .gesture(combined) Since iOS 15 this no longer works. Instead I can drag the view around after the long press, but as soon as I attempt a resize using the magnification gesture the whole app freezes. I have tried attaching the magnification gesture to different pieces of the view thinking that maybe it needs to be at a different level (parent/child) from the drag gesture, but I get the same behavior if there is a drag gesture and a magnification gesture in the same view. It doesn't seem to matter how I attach them, if they both exist in the same view it causes the whole app to become unresponsive. Does anyone know how to overcome this? Is this the new "intended" functionality? If so what do we do for the users who are accustomed to being able to seamlessly drag something and then resize it? Thank you in advance.
Posted
by jforward5.
Last updated
.
Post not yet marked as solved
1 Replies
745 Views
I am trying to allow my users to make something like a collage in my app by pasting images into the canvasView, but I can't find any documentation on how to use the paste function for canvasView. I have tried the code below to paste from the UIPasteboard.general into the canvasView, and the system tells me the paste was successful but I don't see anything in the canvasView. Here is my function, called when the user taps the "paste" button in my UI: private func pasteContent() {         let pasteBoard = UIPasteboard.general                  if paste {             if pasteBoard.hasImages {                 canvasView.paste(pasteBoard.image)                 paste.toggle()             } else if pasteBoard.hasStrings {                 canvasView.paste(pasteBoard.string)                 paste.toggle()             }         }     } Also note, I am using SwiftUI, but this doesn't seem to work in regular swift either. Any thoughts?
Posted
by jforward5.
Last updated
.