Posts

Post marked as solved
1 Replies
461 Views
Here is the simplified resource download snippet: let url = "https://huggingface.co/pcuenq/coreml-stable-diffusion/resolve/main/coreml-stable-diffusion-v1-5_original_compiled.zip" // .background allows downloads to proceed in the background let config = URLSessionConfiguration.background(withIdentifier: "net.pcuenca.diffusion.download") let urlSession = URLSession(configuration: config, delegate: self, delegateQueue: OperationQueue()) urlSession.getAllTasks { tasks in // If there's an existing pending background task with the same URL, let it proceed. guard tasks.filter({ $0.originalRequest?.url == url }).isEmpty else { print("Already downloading \(url)") return } print("Starting download of \(url)") urlSession.downloadTask(with: url).resume() } From the background network speed monitoring and printed log, you can see that the resource is in the downloading state. However, the Debug Navigator does not show the Network downloading state. Xcode: Version 14.3.1 (14E300c)
Posted
by ylqylq001.
Last updated
.
Post not yet marked as solved
0 Replies
520 Views
I according to the https://www.kodeco.com/520-on-demand-resources-in-ios-tutorial article to set some resource files to ODR (On-Demand Resources) and add some tags. But when the Simulator was running, I couldn't find any Tags in the Debug Navigator, it show "No Resources". Xcode: Version 14.3 (14E222b) iPadOS Simulator: 16.4
Posted
by ylqylq001.
Last updated
.
Post not yet marked as solved
0 Replies
895 Views
How can I use PKCanvasView in PencilKit to create multiple layers? These views are superimposed on each other. I want the drawing of each layer is kept independent from each other. It's also important that when the user uses the drag or zoom gesture on it, all layers MUST be scaled or dragged at the same time. Please provide a more concise, efficient and appropriate code implementation. Thanks.
Posted
by ylqylq001.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
I'm trying to learn SwiftUI, and I had a question about how to make a component that has a handle on it which you can use to drag around. There are several tutorials online about how to make a draggable component, but none of them exactly answer the question I have, so I thought I would seek the wisdom of you fine people. Lets say you have a view that's like a window with a title bar. For simplicity's sake, lets make it like this: struct WindowView: View { var body: some View { VStack(spacing:0) { Color.red .frame(height:25) Color.blue } } } I.e. the red part at the top is the title bar, and the main body of the component is the blue area. Now, this window view is contained inside another view, and you can drag it around. The way I've read it, you should do something like this (very simplified): struct ContainerView: View { @State private var loc = CGPoint(x:150, y:150); var body: some View { ZStack { WindowView() .frame(width:100, height:100) .position(loc) .gesture(DragGesture() .onChanged { value in loc = value.location } ) } } } and that indeed lets you drag the component around (ignore for now that we're always dragging by the center of the image, it's not really the point): However, this is NOT what I want: I don't want you to be able to drag the component around by just dragging inside the window, I only want to drag it around by dragging the red title bar. But the red title-bar is hidden somewhere inside of WindowView. I don't want to move the @State variable containing the position to inside the WindowView, it seems to me much more logical to have that inside ContainerView. But then I need to somehow forward the gesture into the embedded title bar. I imagine the best way would be for the ContainerView to look something like this: struct WindowView: View { @State private var loc = CGPoint(x:150, y:150); var body: some View { VStack { Color.red .frame(height:25) .gesture(DragGesture() .onChanged { value in loc = value.location } ) Color.blue } .frame(width:100, height:100) .offset(loc) } } but I don't know how you would implement that .titleBarGesture in the correct way (or if this is even the proper way to do it. should the gesture be an argument to the WindowView constructor?). Can anyone help me out, give me some pointers? Thanks in advance!
Posted
by ylqylq001.
Last updated
.