Я пытаюсь сделать приложение фонарик для своего iPhone. Я имею iPhone 4 и хотел бы использовать Вовлеченный мой iPhone для моего проекта. Кто-либо может помочь мне начать с этим?
Используйте следующее:
AVCaptureSession * session = [[AVCaptureSession alloc] init];
[session beginConfiguration];
AVCaptureDevice * device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
[device unlockForConfiguration];
AVCaptureDeviceInput * flashInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
if (flashInput){
[session addInput:flashInput];
}
AVCaptureVideoDataOutput * output = [[AVCaptureVideoDataOutput alloc] init];
[session addOutput:output];
[output release];
[session commitConfiguration];
[session startRunning];
}
[self setTorchSession:session];
[session release];