如何启用iPhone相机按钮(变焦,闪光灯,开关)

时间:2011-04-23 07:40:41

标签: iphone ios sdk

我正在尝试将相机用于我的应用程序,但问题是当我使用此代码时前置相机被禁用:

 ipc.cameraDevice = UIImagePickerControllerCameraDeviceRear;

反之亦然!

  ipc.cameraDevice = UIImagePickerControllerCameraDeviceFront;

如何将它们组合在一起?我的意思是启用开关按钮使用前后摄像头,!!!所有按钮都被禁用!变焦,闪光灯,相机开关

代码:

-(IBAction)takePic {


    USImage.hidden = YES;
    ipc = [[UIImagePickerController alloc]init];

    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera; 



    ipc.cameraDevice = UIImagePickerControllerCameraCaptureModePhoto;
    ipc.cameraViewTransform = YES;

    [self presentModalViewController:ipc animated:YES];
}

3 个答案:

答案 0 :(得分:2)

我使用此代码,它让我可以完美地切换相机:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];

答案 1 :(得分:0)

你不能同时使用它们

答案 2 :(得分:0)

只是不要同时提供这两行;)。如果你没有设置cameraDevice,那么你的ImagePickerController上会显示按钮(并且像魅力一样工作)