I have added a uiswitch and want to move it to another position via gesture. but uipangesture is not working on uiswitch.. below is my code
UISwitch *swich = [[UISwitch alloc]initWithFrame:CGRectMake(20, 20, 40, 50)];
swich.userInteractionEnabled = YES;
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(switchdraged:)];
[swich addGestureRecognizer:gesture];
[self.view addSubview:swich];
function switchdraged is not being called..
below is switchdraged function
- (void)switchdraged:(UIPanGestureRecognizer *) gesture1
{
UISwitch *swich = (UISwitch *)gesture1.view;
CGPoint translation = [gesture1 translationInView:swich];
swich.center = CGPointMake(swich.center.x + translation.x,
swich.center.y + translation.y);
// reset translation
[gesture1 setTranslation:CGPointZero inView:swich];
}