Commit 4c4ec645 by Javier Heisekce

Mostramos números correctamente

parent ef27a35c
...@@ -25,7 +25,7 @@ class ContactsViewController: UIViewController { ...@@ -25,7 +25,7 @@ class ContactsViewController: UIViewController {
func importContacts() { func importContacts() {
let keys = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactImageDataKey, CNContactImageDataAvailableKey] as [Any] let keys = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactImageDataKey] as [Any]
let request = CNContactFetchRequest( keysToFetch: keys as! [CNKeyDescriptor]) let request = CNContactFetchRequest( keysToFetch: keys as! [CNKeyDescriptor])
request.sortOrder = CNContactSortOrder.givenName request.sortOrder = CNContactSortOrder.givenName
do { do {
...@@ -52,9 +52,6 @@ class ContactsViewController: UIViewController { ...@@ -52,9 +52,6 @@ class ContactsViewController: UIViewController {
} }
} }
self.contactStructArray.append(ContactStruct(isExpanded: true, contacts: contacts, letter: auxLetter)) //agregamos el ultimo nombre self.contactStructArray.append(ContactStruct(isExpanded: true, contacts: contacts, letter: auxLetter)) //agregamos el ultimo nombre
print("CONTACTOS ORDENADOS")
print(self.contactStructArray)
print("======================")
} }
catch { catch {
print("unable to fetch contacts") print("unable to fetch contacts")
......
...@@ -14,24 +14,40 @@ class SingleContactViewController: UIViewController { ...@@ -14,24 +14,40 @@ class SingleContactViewController: UIViewController {
@IBOutlet weak var contactFullname: UILabel! @IBOutlet weak var contactFullname: UILabel!
var selectedContact : CNContact? var selectedContact : CNContact?
@IBOutlet weak var profilePic: UIImageView! @IBOutlet weak var profilePic: UIImageView!
@IBOutlet weak var phoneNumber: UILabel! @IBOutlet weak var phoneNumber: UIButton!
@IBOutlet weak var otherPhoneNumber: UIButton!
@IBOutlet weak var otherPhoneLabel: UILabel!
@IBOutlet weak var phoneLabel: UILabel!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
if let contact = selectedContact{ if let contact = selectedContact{
title = "\(contact.givenName) \(contact.familyName)" title = "\(contact.givenName) \(contact.familyName)"
contactFullname.text = "\(contact.givenName) \(contact.familyName)" contactFullname.text = "\(contact.givenName) \(contact.familyName)"
//phoneNumber.text = CNLabeledValue.localizedStringForLabel(contact.phoneNumbers) if let phones = contact.phoneNumbers.first {
let phoneTitle :String = CNLabeledValue<NSString>.localizedString(forLabel: phones.label! )
if contact.imageDataAvailable { phoneLabel.text = phoneTitle
if let image = contact.imageData { phoneNumber.setTitle(phones.value.stringValue, for: .normal)
if let imageData = UIImage(data: image){ phoneLabel.isHidden = false
profilePic.image = imageData phoneNumber.isHidden = false
} }
if contact.phoneNumbers.last != contact.phoneNumbers.first, let phones = contact.phoneNumbers.last {
let phoneTitle :String = CNLabeledValue<NSString>.localizedString(forLabel: phones.label! )
otherPhoneLabel.text = phoneTitle
otherPhoneNumber.setTitle(phones.value.stringValue, for: .normal)
otherPhoneLabel.isHidden = false
otherPhoneNumber.isHidden = false
}
if let image = contact.imageData {
profilePic.layer.cornerRadius = profilePic.frame.height / 2
if let imageData = UIImage(data: image){
profilePic.image = imageData
} }
} }
} }
} }
@IBAction func callButton(_ sender: Any) {
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment