简体   繁体   中英

How to show picture inside CNContactViewController(forUnknownContact:)

How would I get an image inside CNContactViewController(forUnknownContact:)

I tried something like this:

    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...
    }

Trying to add the image like this:

  aContact.imageData = UIImagePNGRepresentation(profilePicture.image!) 

Unfortunately, this doesn't work and I could not find any other solutions, therefore I am asking: Is there a way to show a picture inside CNContactViewController ?

This is how I want it to be: 史莱克的形象

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM