I am changing position a view and this view back to first position and gives this output:
This application is modifying the autolayout engine from a background thread
after the engine was accessed from the main thread.
This can lead to engine corruption and weird crashes.
Stack:(
0 CoreFoundation 0x000000019083aff0 <redacted> + 148
1 libobjc.A.dylib 0x000000018f29c538 objc_exception_throw + 56
2 CoreFoundation 0x000000019083af20 <redacted> + 0
3 Foundation 0x000000019142c338 <redacted> + 128
4 Foundation 0x00000001912749e8 <redacted> + 36
5 UIKit 0x00000001972c3e54 <redacted> + 72
6 UIKit 0x0000000196967120 <redacted> + 1144
7 QuartzCore 0x0000000193b57274 <redacted> + 148
8 QuartzCore 0x0000000193b4bde8 <redacted> + 292
9 QuartzCore 0x0000000193b4bca8 <redacted> + 32
10 QuartzCore 0x0000000193ac7360 <redacted> + 252
11 QuartzCore 0x0000000193aee3c0 <redacted> + 504
12 QuartzCore 0x0000000193aee6ec <redacted> + 244
13 libsystem_pthread.dylib 0x000000018f8fbef0 <redacted> + 572
14 libsystem_pthread.dylib 0x000000018f8fbc18 <redacted> + 200
15 libsystem_pthread.dylib 0x000000018f8fb2a8 _pthread_wqthread + 1312
16 libsystem_pthread.dylib 0x000000018f8fad7c start_wqthread + 4
)
Also I have a this code in my controller:
DispatchQueue.global(qos: .userInitiated).async {
//some codes which i been waiting
DispatchQueue.main.async {
//some codes wait done
}
}
And my changing position code(its pan gesture):
@IBAction func panSearchView(_ sender: UIPanGestureRecognizer) {
let translation = sender.translation(in: self.view)
var y = sender.view!.center.y + translation.y
if y > self.view.frame.size.height - 50 {
y = self.view.frame.size.height - 50
}else if y < 200{
y = 200
}
sender.view!.center = CGPoint(x: self.view!.center.x, y: y)
sender.setTranslation(CGPoint.zero, in: self.view)
}
How can I fix this?