iOS 8 UIImagePickerController只拍照片照片

时间:2014-11-18 14:18:12

标签: ios objective-c ios8

我正在使用UIImagePickerController sourceType = UIImagePickerControllerSourceTypeCamera;

但是我想指定我只想拍摄照片,而不是视频(在原生相机用户可以切换到视频)有没有办法这样做?

以下是我正在使用的代码:

    if (([UIImagePickerController isSourceTypeAvailable:
      UIImagePickerControllerSourceTypeCamera] == NO))
    return ;
    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    // Displays a control that allows the user to choose picture or
    // movie capture, if both are available:
    cameraUI.mediaTypes =
    [UIImagePickerController availableMediaTypesForSourceType:
     UIImagePickerControllerSourceTypeCamera];
    // Hides the controls for moving & scaling pictures, or for
    // trimming movies. To instead show the controls, use YES.
    cameraUI.allowsEditing = NO;
    cameraUI.delegate = self;
    [self presentViewController:cameraUI animated:YES completion:nil];

我的第一个猜测是改变sourceType = UIImagePickerControllerSourceTypeCamera;,但其他选项是画廊选项。

我的第二个猜测是:改变mediaTypes的数组,但我不知道哪一个

1 个答案:

答案 0 :(得分:7)