Re: Tracking Multiple Touches For Appropriate Label
Re: Tracking Multiple Touches For Appropriate Label
- Subject: Re: Tracking Multiple Touches For Appropriate Label
- From: Chunk 1978 <email@hidden>
- Date: Mon, 7 Dec 2009 22:08:04 -0500
is this suppose to work for multiple touches where one touch is
already present, then another touches the screen? it's not working
for me. each time i touch the screen and add an object to the
myTouches array the return count always returns 1, no matter how many
fingers i already have touching the screen.
On Mon, Dec 7, 2009 at 8:09 PM, mmalc Crawford <email@hidden> wrote:
>
> On Dec 7, 2009, at 4:12 pm, Chunk 1978 wrote:
>
>> if ([[[event allTouches] anyObject] view] == self)
>> {
>> for (UITouch *touch in touches)
>> {
>> CGPoint touchPoint = [[touches anyObject] locationInView:self];
>> switch ([touches count])
>> {
>> case 1: [self Touch1:touchPoint];
>> break;
>>
> This logic doesn't make sense at all.
> Moreover the custom method doesn't follow any standard Cocoa naming conventions.
>
> You probably want something more like:
>
>
> - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
>
> NSMutableArray *myTouches = [[NSMutableArray alloc] initWithCapacity:5];
> NSArray *myLabels = [[NSArray alloc] initWithObjects:touchLabel1, touchLabel2, touchLabel3, touchLabel4, touchLabel5, nil];
>
> UITouch *touch;
>
> for (touch in touches) {
> if (touch.view == self) {
> [myTouches addObject:touch];
> }
> }
>
> NSUInteger i, count;
> count = [myTouches count];
>
> for (i = 0; i < 5; i++) {
> UILabel *label = [myLabels objectAtIndex:i];
> NSString *text = @"";
> if (i < count) {
> UITouch *touch = [myTouches objectAtIndex:i];
> text = NSStringFromCGPoint([touch locationInView:self]);
> }
> label.text = text;
> }
>
> [myTouches release];
> [myLabels release];
> }
>
> (First pass, there may be a better strategy, but at least this will work.)
>
> 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