0
我有一個UISlider,它工作正常,如果我想改變值+,但當我回到 - 時,效果不好。我的應用程序是一個手電筒,我從滑塊中改變了膚色的頻率。任何可以幫助我的ideea?Uislider的價值當回到-
滑塊的索引是可以的。這是我的代碼。
if ([self.lightON.currentImage isEqual:[UIImage imageNamed:@"off-1.png"]]) {
if (slider.value==0) {
AVCaptureDevice * captDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[captDevice lockForConfiguration:nil];
[captDevice setTorchMode:AVCaptureTorchModeOn];
[captDevice unlockForConfiguration];
}
if (slider.value==1){
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(toggleFlashlight) userInfo:nil repeats:YES];
}
if (slider.value==2) {
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(toggleFlashlight) userInfo:nil repeats:YES];
}
if (slider.value==3) {
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(toggleFlashlight) userInfo:nil repeats:YES];
}
if (slider.value==4) {
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(toggleFlashlight) userInfo:nil repeats:YES];
}
if (slider.value==5) {
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(toggleFlashlight) userInfo:nil repeats:YES];
}
}
什麼是不正確的工作?你有沒有使計時器無效? – Wain 2015-02-09 07:49:45
它不適用於使用slider.value的計時器進行手電筒照明。我只有當我想停止燈光時才使計時器無效 – 2015-02-09 08:15:28