Commit 4c4ec645 by Javier Heisekce

Mostramos números correctamente

parent ef27a35c
......@@ -25,7 +25,7 @@ class ContactsViewController: UIViewController {
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])
request.sortOrder = CNContactSortOrder.givenName
do {
......@@ -52,9 +52,6 @@ class ContactsViewController: UIViewController {
}
}
self.contactStructArray.append(ContactStruct(isExpanded: true, contacts: contacts, letter: auxLetter)) //agregamos el ultimo nombre
print("CONTACTOS ORDENADOS")
print(self.contactStructArray)
print("======================")
}
catch {
print("unable to fetch contacts")
......
......@@ -14,24 +14,40 @@ class SingleContactViewController: UIViewController {
@IBOutlet weak var contactFullname: UILabel!
var selectedContact : CNContact?
@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() {
super.viewDidLoad()
if let contact = selectedContact{
title = "\(contact.givenName) \(contact.familyName)"
contactFullname.text = "\(contact.givenName) \(contact.familyName)"
//phoneNumber.text = CNLabeledValue.localizedStringForLabel(contact.phoneNumbers)
if contact.imageDataAvailable {
if let image = contact.imageData {
if let imageData = UIImage(data: image){
profilePic.image = imageData
}
if let phones = contact.phoneNumbers.first {
let phoneTitle :String = CNLabeledValue<NSString>.localizedString(forLabel: phones.label! )
phoneLabel.text = phoneTitle
phoneNumber.setTitle(phones.value.stringValue, for: .normal)
phoneLabel.isHidden = false
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