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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]