UITouch's function locationInView not working with iOS4.2
UITouch's function locationInView not working with iOS4.2
- Subject: UITouch's function locationInView not working with iOS4.2
- From: Angelica Grace Tanchico <email@hidden>
- Date: Wed, 3 Nov 2010 15:01:54 +0800
- Importance: Normal
Hello,
Why is it that UITouch's function locationInView not working with iOS4.2?
I have a table view with a UISwitch on each cell and added an action for a value change event.
It was successfully running with iOS4.1 and below but with iOS4.2, it is not working.
Do you have any suggestion how get a table view's row with a touch event? How?
Thanks in advance!
My code snippets are below:
CREATION OF UISWITCH:
<<snip>>
UISwitch *switchCtl = [[UISwitch alloc] initWithFrame:frame];
[switchCtl addTarget:self action:@selector(switchAction:event:) forControlEvents:UIControlEventValueChanged];
<<snip>>
THE switchAction() FUNCTION:
- (void)switchAction:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView: self.tblView];
NSLog(@"switchAction: x=%f, y=%f", currentTouchPosition.x, currentTouchPosition.y);
NSIndexPath *indexPath = [self.tblView indexPathForRowAtPoint: currentTouchPosition];
NSLog(@"switchAction: indexPath.row = %d", indexPath.row);
<<snip>>
}
Regards,
Angie
_______________________________________________
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