title: Multiple touch problem using UITouch/UIView in iphone
body: <p>I am trying to implement a 2-finger "pinch" and "expand" (or enlarge) on a UIView using iPhone 3G and SDK 3.1.2. I haven't done programmed in UITouch/UIEvent before, so I appreciate any guidance to the problem I am facing.</p>
  
  <p>When I touch the screen with 2 fingers I see that sometimes "touchesBegan" gives me only 1 event. I need UITouch event count == 2 to measure the distance between 2 fingers.</p>
  
  <p>Hence I have to lift up my fingers and repeat this process again till I get both fingers to be detected. Is there a way around? Can I improve it?
  The actual resize works correctly once both fingers are detected but this issue seen at the start needs to be resolved.</p>
  
  <p>I know SDK 3.2 detects gestures such as pinch but I was wondering how it can be done in 3.1.2?</p>
  
  <p>The code is given below. The "OnFingerDown" function gets called randomly even when I put 2 fingers down whereas I want "onTwoFingersDown" to be called each time. Moreover the I get only 1 touch event each time I put my fingers down. I mean if "OnFingerDown" was called twice I could somehow get it to work.</p>
  
  <p>Thanks in advance. Appreciate any help.</p>
  
  <p>John</p>
  
  <pre><code> - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
  
  {
  
       UITouch* touch, *touch1;
       CGPoint location, location1;
       if([[event allTouches] count] == 1) {
  
                 touch=[UI[[event allTouches] allObjects] objectAtIndex:0];
                 location=[touch locationInView:self];
                 OnFingerDown(location);
       }
       else if([[event allTouches] count] == 2) {
  
            touch=[[[event allTouches] allObjects] objectAtIndex:0];
            location=[touch locationInView:self];
            touch1=[[[event allTouches] allObjects] objectAtIndex:1];
            location1=[touch1 locationInView:self];
  
            OnTwoFingersDown(location, location1);
  
       }
  
  }
  </code></pre>