问题
I have trouble showing the camera controls when using UIImagePickerController. Specifically, I need to be able to select between slo-mo, video, photo, square and pano.
The essential part of code I use is:
UIImagePickerController *pc = [[UIImagePickerController alloc] init];
[pc setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
pc.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, nil];
But this shows a picker controller with the ability to take a picture only i.e., no square nor pano modes either.
Setting pc.mediaTypes to:
pc.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie, nil];
..shows a picker controller with video and photo. But how do I get the other camera modes/types to show? E.g. what is the UTType for pano?
回答1:
UIImagePickerController doesn't give you Apple's whole Camera app to use inside of your own app. Not all of the functionality of the Camera app is available. You can print available media types by calling -[UIImagePicker availableMediaTypesForSourceType:] and you'll find that you get kUTTypeImage and kUTTypeMovie.
Square, slo-mo, time-lapse, and panorama functionalities are not provided by UIImagePickerController.
回答2:
UIImagePickerController came out in iOS 2.0, and was probably modern, in its time:
https://developer.apple.com/documentation/uikit/uiimagepickercontroller?language=objc
What you see are "standard controls".
Even today the modern documentation points to the legacy (Objective-C era docs)
The styling of the chrome has changed, but as they say: "the song remains the same."
There are hooks to hide standard controls, and then you can add your own customer controls to operate the camera programatically. I have a pet project to make a version of time-lapse, etc.
But for serious projects, Apple suggests using the AV frameworks, and although I haven't started using them, I certainly agree.
来源:https://stackoverflow.com/questions/33813002/how-to-show-all-camera-controls-with-for-uiimagepickercontroller