我正在爲iPhone 4/4S製作密碼應用程序。當用戶輸入密碼失敗3次時,我想用iPhone的前置攝像頭拍攝用戶的電影。這不是什麼新鮮事,appstore中的很多應用程序都做類似的事情。拍攝這個傢伙的照片,獲取他的GEO座標等。使用UIImagePickerController祕密錄製電影
我面臨的挑戰是,當我嘗試設置電影錄製時,攝像頭覆蓋佔據了整個屏幕。我真正想要做的是讓用戶仍然看到登錄屏幕和按鈕,但祕密記錄和製作用戶的電影。有什麼辦法可以做到這一點?
這是我正在使用的代碼。
在我的* .h文件@interface v1InstantController : UIViewController <UIImagePickerControllerDelegate>
{
UIImagePickerController *picpicker;
}
@property (nonatomic, retain) UIImagePickerController *picpicker;
在我的* .m文件
-(IBAction) makeMovieNow
{
picpicker = [[UIImagePickerController alloc] init];
picpicker.delegate = self;
picpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picpicker.sourceType = UIImagePickerControllerSourceTypeCamera;
picpicker.showsCameraControls = NO;
picpicker.navigationBarHidden = YES;
picpicker.wantsFullScreenLayout = NO;
picpicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picpicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picpicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
picpicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picpicker.videoQuality = UIImagePickerControllerQualityTypeHigh;
picpicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
//The problem is right here!
//picpicker.cameraViewTransform = CGAffineTransformScale(picpicker.cameraViewTransform, 0.01, 0.01);
[self presentModalViewController:picpicker animated:YES];
[picpicker startVideoCapture];
}
的問題就在這裏 「presentModalViewController:picpicker」。當我使用它時,它會啓動帶有鳶尾花飛濺等的相機屏幕,並顯示整個屏幕上正在記錄的內容。即使我使用cameraViewTransform,它仍會禁用頁面上的任何內容,並將此相機覆蓋圖放在頁面中間。 (帶有一個非常小的相機覆蓋)我不希望用戶知道我正在錄製,並希望他認爲它像往常一樣生意。即讓他繼續嘗試在頁面上輸入密碼失敗。
你知道的任何工作示例/樣品碼? – 2012-08-16 14:07:44
有幾個示例項目可用:[AVCam](https://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112)的基礎知識,[SquareCam](https://developer.apple.com/library/ios/#samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190)也會很有趣。 – 2012-08-16 14:34:51