UIPanGestureRecognizer - Avoid moving two images simultaneously - Swift - swift

I have a ViewController with 3 UIImageView with its images. I am using Pinch, Pan and Rotate gesture on all three images. While doing Pinch or Rotation i got two finger point with opt+mouse_click. There in the finger point, if two images are pointed with each finger point, both images are moving around.
I actually don't want that move(pan) while doing opt+mouse_click, just need to rotate or zoom the images with two finger points.
Help me to resolve, Thanks in advance

You can try to limit the UIPanGestureRecognizer 's finger that touch on screen to 1 to avoid it. Rotate or zoom will need 2 fingers.
More information from Apple's doc
The maximum number of fingers that can be touching the view for this gesture to be recognized.
https://developer.apple.com/documentation/uikit/uipangesturerecognizer/1621208-maximumnumberoftouches

Related

How to make a menu with icons spinning in a circle?

I am trying to create a menu for my app with a few icons in a circle. User should be able to spin this menu, making the icons change their positions around this circle path, but not rotating themselves. I read this earlier http://www.raywenderlich.com/9864/how-to-create-a-rotating-wheel-control-with-uikit so I can see how to follow the finger movement, but I need this menu to have inertial spin after the touch ends. I have 2 questions about how to do this.
First one, what's the best way to make animation with icons moving around in a circle? It should be slowing down until it stops and, if user moves his finger fast enough, should be able to do more than one full circle.
Second, how do I measure speed of finger movement at the end of it? I tried to use locationInView and previousLocationInView and just spin it by difference of angles between them multiplied by some constant. Problem is, when I keep my finger in one place for a while and take it up, I still get inertial movement of the circle and in this case I don't want it to move at all.
You want to use a scroll view. Specifically you want a hidden scroll view where you attach the pan gesture recogniser from the scroll view to your custom menu view. Then you implement the delegate methods of the scroll view to redraw your menu. This WWDC video has a good overview of the process. The benefit of this approach is that you get true iOS style acceleration and deceleration for free. You don't need to worry about finger position or speed, only the content offset of the scroll view.
Unless you want to spin your finger round in a circle with the menu items. That's a different ball game...
In theory, the same approach as above can be used for spinning your finger in a circle. You would need to ensure that directionalLockEnabled was set to NO on the scroll view. The problem is that the calculations to determine the rotation of your menu view are a lot more complex. Probably you would want to be modal and check if the scroll view is dragging in the callbacks. If it is dragging you would use the touches on the pan gesture to find the exact finger location to set the rotation. You'd also want to maintain data on the instantaneous direction of finger movement so that when the touch is released... If it isn't dragging then you use the scroll view content offset to apply the deceleration effect on the rotation (using the scroll direction just before the touch was released to know how to use the content offset changes).

Sliding finger across multiple image views

I have dynamically created a grid of 8x8 image views over which letters are displayed and assigned the tag to each.I can detect the touch on each image view through Tap Gestures but what I want now is : if the user slide its finger across the letters, i would be able to get the each image view tag. So that the letters touched can be detected(the continuous touch).
Please Help,
Thanks In Advance.
Disable user interaction on the individual image views and handle touches on the superview containing them instead. Then you can figure out which image the user's finger is over in touchesMoved.
As the other poster said, you need to handle the touch events on the superview. You could use touchesBegan/touchesMoved, or you could add a pan gesture recognizer to the superview. Personally, I prefer gesture recognizers. I find them cleaner and easier to use, so I'd go that route.

UIView Rotation using CGAffineTransform

I want to rotate an UIView using CGAffineTransform and I'm able to rotate View using CGAffineTransform.
But I want to rotate UIView smoothly on finger touch based on swipe gestures.
So like right swipe, left swipe I was able to detect swipe but when I swipe from down to right or from down to left, I'm not able to detect swipe gesture of these types...
Sanjay these are the only allowable gestures that a iPhone supports
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UISwipeGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instp/UISwipeGestureRecognizer/direction
so I think you are trying to recognize a diagonal swipe gesture and the its not working.
and also there is a minimum numberOfTouchesRequired required for swipe gesture.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UISwipeGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UISwipeGestureRecognizer
And if you want to rotate a UIView object than I think you will find the code in this link
rotating a view on touch
Hope this helps.

problem in quartz 2D drawing touches began

I have drawn 5 circles in in my app one above the other . But i want to perform different operations when i touch each circle and there is only one touches began where I can perform touches for the entire view.. can anyone help me how to do that.
Either process the coordinates of the touch to "grab" a specific circle (you know their coordinates if you have the origins and radii), or put each circle into its own view, and make five subviews/circles of a parent view. Pass the touch down the view chain until the coordinates overlap.

Rotate a UIImageView with a touch gesture - iphone dev

Been having real trouble with this one and wondered if someone may have found a solution to this issue.
I would like to be able to rotate a UIImageView using a touch gesture
-> So when the user places two fingers on the touch area and rotates their fingers the UIImageView will rotate with them (Rotating in whatever direction the user moves their fingers)
I can do this but with one issue.... as the UIImageView rotates it does not keep its shape. It seems to skew?? It is really strange and i can not understand why it is happening.
So if i start with an equal sided square... as i rotate it does not remain as an equal sided square the sides seem to skew and not remain equal.
SOOOO i was wondering if anyone has come across this issue, or if anyone has successfully rotated a UIImageView with a touch gesture without it skewing.
Any help regarding this issue is highly appreciated.
Cheers
Tom
Can you give us some more information, like the rotation code?
Hopefully you're doing something like the following:
[imageView setTransform: CGAffineTransformMakeRotation(M_PI/2)];