xcode 表达式产生错误:执行被中断,原因:跳过。进程已经返回到表达式求值前的状态

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37789164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:52:50  来源:igfitidea点击:

expression produced error: Execution was interrupted, reason: step over. The process has been returned to the state before expression evaluation

xcodeswift

提问by Sagar

I am just going to new in swift,

我只是要快速进入新的,

I have one button on click of which opening front camera of iPad and clicking the photo of user, and when clicked on use photo,

我有一个点击按钮,打开iPad的前置摄像头并点击用户的照片,当点击使用照片时,

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

is getting called of imagePickerController

被称为 imagePickerController

this is the line of code..

这是代码行..

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

    {
        picker .dismissViewControllerAnimated(true, completion: nil)
        photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage
        if imageData == nil {
            imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 1)
        }
    }

but when I submit it shows found nil value, after debugging got this point in func didFinishPickingMediaWithInfowhich says,

但是当我提交它显示 found nil value,调试后得到了这一点,func didFinishPickingMediaWithInfo其中说,

(lldb) po imageData
expression produced error: Execution was interrupted, reason: step over.
The process has been returned to the state before expression evaluation.

I am not getting what I am doing wrong. as I am not good in swift, can any one please guide me for the same. I am stuck at this point.

我没有明白我做错了什么。由于我不擅长快速,任何人都可以指导我。我被困在这一点上。

Thanks in advance.

提前致谢。

采纳答案by Sagar

I got the solution, Thanks to my colleague,

我得到了解决方案,感谢我的同事,

I am capturing the image from imagePickerController and getting saved in NSData. But the image captured it around 6-7 MB (iPad camera captures the image with this size by default) and when saving it into NSDataand then converting it into base64 format goes out of size and then compiler throws the issue.

我正在从 imagePickerController 捕获图像并保存在NSData. 但是捕获的图像大约为 6-7 MB(iPad 相机默认捕获此大小的图像)并且在将其保存NSData并转换为 base64 格式时会超出大小,然后编译器会抛出问题。

Issue solved just by changing in line code for UIImageJPEGRepresentation

只需更改行代码即可解决问题 UIImageJPEGRepresentation

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
    photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage
    imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 0.5)
    print(imageData)
    picker .dismissViewControllerAnimated(true, completion: nil)
}

回答by becomedragon

I got a solution for video:

我得到了视频的解决方案:

use "PHImageFileSandboxExtensionTokenKey" key

使用“ PHImageFileSandboxExtensionTokenKey”键

[PHImageManager defaultManager] requestAVAssetForVideo:asset options:avRequest resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
                NSString *localPath = info[@"PHImageFileSandboxExtensionTokenKey"];
                if (localPath == nil || [localPath isEqualToString:@""]) {
                    isiCloud = YES;
                } else {
                    isiCloud = NO;
                }

回答by Dershowitz123

You're calling the dissmissViewController(:_)in the beginning. Call it at the end of function and try.

dissmissViewController(:_)在一开始就调用了。在函数结束时调用它并尝试。