Set Flashlight mode to be off as default

Hi,

I am trying to set the Flashlight mode to be off when I take picture or video. this is what I put:

public static void showImagePicker(UIImagePickerControllerSourceType source = UIImagePickerControllerSourceType.Camera, UIImagePickerControllerCameraDevice cameraDevice = UIImagePickerControllerCameraDevice.Rear){
		_picker = new UIImagePickerController();
		_picker.cameraFlashMode = UIImagePickerControllerCameraFlashMode.Off;

It crashes when I run on Xcode. Is there something I need to do before I set this?

Hi, as the exception says in Xcode, “Source type must be UIImagePickerControllerSourceTypeCamera”. So, to set the camera flash mode, you first need to set the picker’s sourceType as camera. To make this method more generic:

_picker = new UIImagePickerController();
_picker.sourceType = source;
if (_picker.sourceType == UIImagePickerControllerSourceType.Camera)
	_picker.cameraFlashMode = UIImagePickerControllerCameraFlashMode.Off;