[ios] ContactsUI에서 연락처의 연락처를 사용자 정의 필드로 확장하는 방법은 무엇인가요?
먼저, CNContactViewController
를 사용하여 사용자로부터 연락처 정보를 입력하거나 편집할 때 사용자 정의 필드를 추가할 수 있습니다. 한편, CNContactPickerViewController
를 사용하여 연락처를 선택하고 표시할 때 사용자 정의 필드를 표시할 수도 있습니다.
아래는 CNContactViewController
에 사용자 정의 필드를 추가하는 예제 코드입니다.
import Contacts
import ContactsUI
func presentContactViewController() {
let contact = CNMutableContact()
// Add custom field
let customField = CNLabeledValue(label: "Custom Label", value: "Custom Field Value")
contact.note = "Additional notes" // You can also use the 'note' field to store custom data
let contactViewController = CNContactViewController(forUnknownContact: contact)
contactViewController.contactStore = CNContactStore()
contactViewController.delegate = self
navigationController?.pushViewController(contactViewController, animated: true)
}
이 예제에서는 CNMutableContact
를 사용하여 연락처를 만들고, CNLabeledValue
를 사용하여 사용자 정의 필드를 추가합니다. 또한, CNContactViewController
를 이용하여 사용자에게 표시될 사용자 정의 필드를 설정합니다.
이 외에도 CNContactPickerViewController
를 사용하여 사용자 정의 필드를 처리하는 방법에 대해 알려드릴 수 있습니다.