I am currently trying to make an image viewer and I want to know if there’s a way to zoom in/out of a canvas picture with two fingers pinching the picture like the regular Photo viewer in iOS.
Any help would be appreciated.
I am currently trying to make an image viewer and I want to know if there’s a way to zoom in/out of a canvas picture with two fingers pinching the picture like the regular Photo viewer in iOS.
Any help would be appreciated.
Use a pinch gesture recognizer from iOSKit and then create a CGAffineTransform and apply it to your image view. The following is Obj-C but should translate easily with iOSKit.
-(void)HandlePinch:(UIPinchGestureRecognizer*)recognizer{
if ([recognizer state] == UIGestureRecognizerStateEnded) {
NSLog(@"======== Scale Applied ===========");
if ([recognizer scale]<1.0f) {
[recognizer setScale:1.0f];
}
CGAffineTransform transform = CGAffineTransformMakeScale([recognizer scale], [recognizer scale]);
imgView.transform = transform;
}
}
By default image views do not receive gestures (same with labels)
This should help
declare sub userInteractionEnabled_ lib uikitlib selector "setUserInteractionEnabled:" (obj_id as ptr, value as boolean)
userInteractionEnabled_(imgView.handle, true)
I am fairly new to XOJO declares. I have the iOSKit setup, but I am not sure how to use the UIPinchGesture class.
Do call the method Extensions.AddGestureRecognizer(myView, myUIPinchGesture) inside a canvas?
My current attempt is to use the iOSGesture class, but the scale parameter given inside the PinchChanged EventHandler is giving me incorrect scale values. It would go into a digit that is in the millions.