如何在CNContactViewController(forUnknownContact:)

时间:2018-07-21 18:43:06

标签: ios swift cncontact cncontactviewcontroller

我如何在CNContactViewController(forUnknownContact:)内获得图像

我尝试过这样的事情:

    fileprivate func showUnknownContactViewController() {
    let aContact = CNMutableContact()
    let newEmail = CNLabeledValue(label: CNLabelWork, value: email! as NSString)
    aContact.emailAddresses.append(newEmail)

    let workPhone = CNLabeledValue(label: CNLabelWork, value: CNPhoneNumber(stringValue : phone!))
    aContact.phoneNumbers.append(workPhone)

    aContact.imageData = UIImagePNGRepresentation(profilePicture.image!)

    //Pushing controller...
    }

尝试添加这样的图像:

    aContact.imageData = UIImagePNGRepresentation(profilePicture.image!)

不幸的是,这不起作用,我找不到其他解决方案,因此我问:有没有办法在CNContactViewController内显示图片?

这就是我希望的样子: Image of shrek

1 个答案:

答案 0 :(得分:2)

因此,在对matt进行了一些研究之后,我发现问题是由我显示的联系人是现有联系人引起的。