0

Possible Duplicate:
Way to make a UIButton continuously fire during a press-and-hold situation?

i have two custom button in camera view, one is zoom in and other one is zoom out both the buttons are pressed value will increase 1,2... , but i want when i press the zoom in or zoom out button the value will increasing automatically and release the button value will stopped,how? please any one help me

I tried the code

zoomin=[UIButton buttonWithType:UIButtonTypeCustom];
    zoomin.frame=CGRectMake(60, 410, 60, 60);
    [zoomin setBackgroundImage:[UIImage imageNamed:@"zoomplus.png"] forState:UIControlStateNormal];
    [zoomin addTarget:self action:@selector(CameraZoomIn) forControlEvents:UIControlEventTouchUpInside];
    [buttonView addSubview:zoomin];

-(void)CameraZoomIn
{
    x=x+0.090253;
    y=y+0.090253;
    NSLog(@"X : %f, Y : %f",x,y);
    imgpicker.cameraViewTransform = CGAffineTransformMakeScale(x,y);
}
Community
  • 1
  • 1
sankar
  • 7
  • 3

2 Answers2

0

Use this code..

 zoomin = [UIButton buttonWithType:UIButtonTypeCustom];
 zoomin = CGRectMake(60, 410, 60, 60);
 UIImage * zoominImage = [UIImage imageNamed:@"zoomplus.png"];
[zoomin setImage:jumpbtnImage forState:UIControlStateNormal];
 zoomin.backgroundColor = [UIColor clearColor];
[zoomin addTarget:self action:@selector(CameraZoomIn) forControlEvents:UIControlEventTouchDown];
[zoomin addTarget:self action:@selector(stopZoom) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview: zoomin];
Anshul Jain
  • 903
  • 6
  • 9
0

You'll need to set NSTimer, that will fire every x time on UIControlEventTouchDown and stop it on UIControlEventTouchUpInside or UIControlEventTouchCancel. When that timer will fire -> do whatever you want with any counter, zoom or any other stuff...

Ariel
  • 2,430
  • 1
  • 17
  • 20