可能重複:
Way to make a UIButton continuously fire during a press-and-hold situation?當我按下按鈕的值會自動增加,怎麼樣?
我有在相機視圖中的兩個自定義按鈕,一個是在變焦和另一種是縮小這兩個按鈕被按下值將增加1,2...
,但我想要當我按下放大或縮小按鈕的值會自動增加和釋放按鈕值將停止,如何?請任何一個幫助我
我試過代碼
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);
}