-
Notifications
You must be signed in to change notification settings - Fork 564
Closed
Milestone
Description
I created a demo app to try to drag and scale shapes using onPan and onPinch events on a rectangle Node. The app has a large background image inside a scroll view, and the macaw view has the same size as the image view. I want to create a rectangle shape over the image, and be able to drag and resize it, but I noticed some memory leak every time I activate an event, crashing the app after some time. I downsized the application to the following lines and it's still retaining memory, though much less. I'm using version 0.9.5. What could be the cause? Is the memory leak normal?
import UIKit
import Macaw
class ViewController: UIViewController {
var macawView = MacawView()
let stroke = Stroke(fill: Color.red, width: 1.0)
var group: Group!
override func viewDidLoad() {
super.viewDidLoad()
configMacawView()
let square = Shape(form: Rect(x: 0, y: 0, w: 80.0, h: 120.0), fill: Color.clear, stroke: stroke)
square.onPan { event in
square.place = square.place.move(dx: event.dx, dy: event.dy)
}
macawView.node = square
}
func configMacawView(){
let imageView = UIImageView()
let image = #imageLiteral(resourceName: "Medical_X-Ray_imaging_AAR02_nevit")
imageView.image = image
imageView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(imageView)
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
imageView.widthAnchor.constraint(equalTo:view.widthAnchor).isActive = true
imageView.heightAnchor.constraint(equalTo:view.heightAnchor).isActive = true
macawView.backgroundColor = .clear
macawView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(macawView)
macawView.centerXAnchor.constraint(equalTo: imageView.centerXAnchor).isActive = true
macawView.centerYAnchor.constraint(equalTo: imageView.centerYAnchor).isActive = true
macawView.widthAnchor.constraint(equalTo:imageView.widthAnchor).isActive = true
macawView.heightAnchor.constraint(equalTo:imageView.heightAnchor).isActive = true
}
}