由于UISignPickerController中的指针从可用列表中出队而导致的无效签名,导致应用程序崩溃 [英] App Crashed due to Invalid signature for pointer dequeued from free list in UIImagePickerController

查看:71
本文介绍了由于UISignPickerController中的指针从可用列表中出队而导致的无效签名,导致应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UIImagePickerController 选择中遇到问题.当我从图片库中选择来源时,由于无效的指针从空闲列表中出队,应用崩溃.然后,如果我再次运行,则可以使用相同的代码正常工作.我在Google上搜索,发现与我的查询有关的一个问题.

I am facing problem in UIImagePickerController selection. When I choose source from Photo Library App crashes due to Invalid signature for pointer dequeued from free list. then If I run again it works fine with the same code. I searched on google and found one question related to my query Xcode - My app crash and the error is "Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug" .

但是在我的情况下解决方案不起作用.

but solution isn't working in my case.

我正在使用Xcode 8.1,部署目标是8.0.

I am using Xcode 8.1 and my deployment Target is 8.0.

推荐答案

由于@luke要求提供UIImagePickerViewController的代码:

As @luke requested for the code for UIImagePickerViewController:

    let pickerView = UIImagePickerController()
    pickerView.delegate = self
    pickerView.allowsEditing = true

    pickerView.sourceType = .photoLibrary

    let authStatus = PHPhotoLibrary.authorizationStatus() // Get the current authorization state.
    // print(authStatus)


    if (authStatus == PHAuthorizationStatus.notDetermined) {

        // Access has not been determined.
        PHPhotoLibrary.requestAuthorization({ (newStatus) in

            if (newStatus == PHAuthorizationStatus.authorized) {
                self.present(pickerView, animated: true, completion: { _ in })

            }

            else {

            }
        })

    } else if authStatus == PHAuthorizationStatus.authorized {
        print("Access has been granted.")

        self.present(pickerView, animated: true, completion: { _ in })

    }  else if (authStatus == PHAuthorizationStatus.denied) {
        print("Access has been denied.")

    }
    else if (authStatus == PHAuthorizationStatus.restricted) {

        print("Restricted access - normally won't happen.")

    }

现在,当用户选择特定图像时: 该方法将被称为:

Now when the user picks a particular image: This method will be called:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    //print(info)
    if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
            YOUR_GLOBAL_IMAGE_VIEW?.contentMode = .scaleAspectFit
            YOUR_GLOBAL_IMAGE_VIEW?.image = pickedImage

        }
    }

    dismiss(animated: true, completion: nil)
}

别忘了导入PhotosUIUIImagePickerControllerDelegate.

这篇关于由于UISignPickerController中的指针从可用列表中出队而导致的无效签名,导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆