• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tracking Multiple Touches For Appropriate Label
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking Multiple Touches For Appropriate Label


  • Subject: Re: Tracking Multiple Touches For Appropriate Label
  • From: Chunk 1978 <email@hidden>
  • Date: Tue, 8 Dec 2009 11:59:35 -0500

this is what i have so far, but i have no idea how to write the
touchesEnded method so that the appropriate label will clear.  so if 3
fingers are touching the screen and displaying their different
coordinates, if the 2nd finger that was pressed ends its touch, the
2nd label will clear ("Touch 2: {0, 0}") while the 1st and 3rd
continue to track.  clearly i'm lost, i apologize.

- (void)viewDidLoad
       {
       labelsArray = [[NSArray alloc] initWithObjects:touchLabe1,
touchLabe2, touchLabe3, nil];
       touchesArray = [[NSMutableArray alloc] initWithCapacity:3];
       }

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
       {
       for (UITouch *touch in touches)
               [touchesArray addObject:touch];

       for (NSUInteger i = 0; i < 3; i++)
               {
               UILabel *aLabel = [labelsArray objectAtIndex:i];
               if (i < [touchesArray count])
                       {
                       UITouch *touch = [touchesArray objectAtIndex:i];
                       NSString *point = NSStringFromCGPoint([touch
locationInView:self.view]);
                       aLabel.text = [NSString
stringWithFormat:@"Title %i:\n%@", i+1, point];
                       }
               }
       }

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
       {
       for (NSUInteger i = 0; i < 3; i++)
               {
               UILabel *aLabel = [labelsArray objectAtIndex:i];
               if (i < [touchesArray count])
                       {
                       UITouch *touch = [touchesArray objectAtIndex:i];
                       NSString *point = NSStringFromCGPoint([touch
locationInView:self.view]);
                       aLabel.text = [NSString
stringWithFormat:@"Title %i:\n%@", i+1, point];
                       }
               }
       }

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
       {
       //??
       }



On Tue, Dec 8, 2009 at 11:01 AM, mmalc Crawford <email@hidden> wrote:
>
> On Dec 8, 2009, at 3:49 am, Chunk 1978 wrote:
>
>> i meant that i find it complicated compared to basic single touches or
>> gestures.
>>
> It's not clear what's complicated.
>
> You typically want to know when touches began, moved, and ended, and there are methods to inform you when each of these things happen (and another to let you know that they've been interrupted).
>
> This is a multi-touch system, so just because one touch began it doesn't mean all did.  So in some cases at least (including, it seems, yours) you need a means to get information about other touches.  The methods therefore all tell you: "Here are the touches that have just entered the phase you're interested in in this method, and here's a data structure (the UIEvent object) that gives you a way to get information about all the current touches".
>
> It's difficult to see how this could be simpler.  About the only simplification could be that the methods could take a single parameter... there are a couple of scenarios for this.  The methods could just pass the UIEvent object -- but then you'd have to iterate through its touches to find the ones that are in the phase you're interested in.  Or you could have two (or three) methods per phase, e.g. touchesBegan: and touchesBeganInEvent: (and maybe again touchesBegan:withEvent:), but then you're making things more complicated again with multiple override points.
>
> mmalc
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Tracking Multiple Touches For Appropriate Label
      • From: mmalc Crawford <email@hidden>
References: 
 >Tracking Multiple Touches For Appropriate Label (From: Chunk 1978 <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: mmalc Crawford <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: Chunk 1978 <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: mmalc Crawford <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: mmalc Crawford <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: Chunk 1978 <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: Graham Cox <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: Chunk 1978 <email@hidden>)
 >Re: Tracking Multiple Touches For Appropriate Label (From: mmalc Crawford <email@hidden>)

  • Prev by Date: Re: NSURLConnection Problem Inside QuickLook Generator
  • Next by Date: Big memory/time consumption in NSTreeController KVO GC
  • Previous by thread: Re: Tracking Multiple Touches For Appropriate Label
  • Next by thread: Re: Tracking Multiple Touches For Appropriate Label
  • Index(es):
    • Date
    • Thread