Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
I wanted to make an application which will generates an animation when i touch image1 and drag it on top of image2.

In addition, I wanted to make it such that when my fingers are on both images and moved, another type of animation will occurs.

I used functions like - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; for my moving of images.

However, how could I make my program detect 2 fingers instead of only 1? I heard people say about using the UIScrollView, but by using that, I don't think I will still able to move the image? Or am i going to use the <UIScrollViewDelegate> protocol?

Correct me if I am wrong, bit noob here.
Help is greatly appreciated.
 

davedelong

macrumors member
Sep 9, 2007
50
0
Right here.
I wanted to make an application which will generates an animation when i touch image1 and drag it on top of image2.

In addition, I wanted to make it such that when my fingers are on both images and moved, another type of animation will occurs.

I used functions like - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; for my moving of images.

However, how could I make my program detect 2 fingers instead of only 1? I heard people say about using the UIScrollView, but by using that, I don't think I will still able to move the image? Or am i going to use the <UIScrollViewDelegate> protocol?

Correct me if I am wrong, bit noob here.
Help is greatly appreciated.

To detect multiple touches, you need to make sure that "Multiple Touch" is enabled for the particular UIView (or subclass thereof). Once you do that, you'll find that the NSSet * touches has more than one UITouch object in it. Each UITouch object corresponds to one finger.

HTH,

Dave
 

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
Thanks for the reply and help given.

So i set my view to allow multipleTouch, but now how do i check if user is using 1 finger dragging or 2 fingers dragging?
 

davedelong

macrumors member
Sep 9, 2007
50
0
Right here.
Thanks for the reply and help given.

So i set my view to allow multipleTouch, but now how do i check if user is using 1 finger dragging or 2 fingers dragging?

Code:
if ([touches count] >= 2) {
  //dragging with two fingers
} else {
  //dragging with one finger
}
 

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
Thanks again for that fast reply.

This is what i wrote:

UITouch *touch = [touches anyObject];
CGPoint location;

if ([touch view] == image)
{
location = [touch locationInView:image];

if([touches count] == 1)
{
NSLog(@"1");
}

else if ([touches count] == 2)
{
NSLog(@"2");
}
}

It doesn't work, it keep showing only 1...is there something i miss?
*I try 2 fingers by pressing alt/option and press on mouse and drag; tested on simulator
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.