在iOS10中点击相机选择拍照不用手动点击那个自动拍照,那么如何通过手动点击创建拍照? 我尝试了以下代码:
- (void)cameraAndPhotogalleryMethod{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picker.showsCameraControls = YES;
[self presentViewController:picker animated:YES
completion:^ {
[picker takePicture];
}];
}
else
{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}}
- (void)cameraMethod{
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picker.showsCameraControls = YES;
[self presentViewController:picker animated:YES
completion:^ {
[picker takePicture];
}];}
答案 0 :(得分:1)
答案 1 :(得分:0)
1.如果你在ios上访问相机10.你应该在plist中添加代码。试试这段代码。
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your photo library</string>