为什么UIAlertController不允许摄像头出现在iOS 12上?
我遇到了一个问题,当点击缩略图时,此操作有效为什么UIAlertController不允许摄像头出现在iOS 12上?,ios,objective-c,iphone,ios12,Ios,Objective C,Iphone,Ios12,我遇到了一个问题,当点击缩略图时,此操作有效 -(IBAction)thumbnailTapped:(UIGestureRecognizer *)tap { if (_customItem.file.isEmpty) { [self openCamera]; // opens camera if no image is present } else { _isTransitioningToFullViewOrCamera
-(IBAction)thumbnailTapped:(UIGestureRecognizer *)tap
{
if (_customItem.file.isEmpty)
{
[self openCamera]; // opens camera if no image is present
}
else
{
_isTransitioningToFullViewOrCamera = true;
[self performSegueWithIdentifier:@"CustomFileViewFromItem" sender:self]; // if file is present then it shows the picture blown up.
}
}
以下代码被称为:
-(无效)打开摄像头
{
_IsTransitioningOfUllVieworCamera=真;
NSString*ext=_customItem.file?_customItem.file.ext:JpgExt;
如果([CustomCameraController isCameraAvailableForExt:ext forViewController:self])
[CustomCameraController启动CameraForExt:ext forViewController:self];
}
但是当从UIAlertAction调用时,相机根本不会打开
UIAlertController *actionSheet;
actionSheet = [UIAlertController alertControllerWithTitle:@"Select an action:" message:nil preferredStyle:UIAlertControllerStyleAlert];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// Cancel button tappped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Replace" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
self dismissViewControllerAnimated:YES completion:^{
}];
[self openCamera];
}]];
// Present action sheet.
[self presentViewController:actionSheet animated:YES completion:nil];
如果[self-openCamera]
是否放置在完成块中,则不会更改任何内容
我想知道是否有人有这方面的经验;当UIAlertController不存在时(如用单次轻触),[自动打开相机]
打开相机,您可以拍照;但是,当在显示UIAlertController后调用此命令时,相机将不会打开,并且会无声地出现故障。“询问,您将收到”
当你已经碰壁好几天没有答案,只是问了问题,然后自己找到答案时,应该有一句格言
答案是置之不理
//self dismissViewControllerAnimated:YES completion:^{
// }];
因为它会取消包含openCamera
功能的视图
我不敢相信我直到现在才意识到这一点
任务完成了!:)