UITouch's function locationInView not working with iOS4.2 (cont)
UITouch's function locationInView not working with iOS4.2 (cont)
- Subject: UITouch's function locationInView not working with iOS4.2 (cont)
- From: Angelica Grace Tanchico <email@hidden>
- Date: Wed, 3 Nov 2010 15:05:06 +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.
According to logs, indexPath.row is always set to 0 with iOS4.2 (with old iOS, it gets the proper row).
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