ContactPickerView不显示..app崩溃

时间:2016-04-02 07:06:41

标签: ios swift xcode7.2

尝试在我的应用中打开“联系人”应用视图以选择和导入联系人时出现此错误。我不确定是什么问题。有人可以帮助解决问题吗?

***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UIViewController openContacts:]:无法识别的选择器发送到实例0x7ff917a10740'

这是我的代码

let contact = CNMutableContact()

var delegate: ViewSevenFiveDelegate!

var tableViewController: ViewTwo? = nil

//Fetch Contacts Information like givenName and familyName, phoneNo, address
let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey]

let store = CNContactStore()

@IBAction func openContacts(sender: AnyObject) {
    //open contacts to add to VCtable

    let contactPickerViewController = CNContactPickerViewController()

    contactPickerViewController.predicateForEnablingContact = NSPredicate(format: "Number != nil")

    contactPickerViewController.displayedPropertyKeys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey]

    contactPickerViewController.delegate = self

    presentViewController(contactPickerViewController, animated: true, completion: nil)
}

func contactPicker(picker: CNContactPickerViewController, didSelectContact contact: CNContact) {
    delegate.didFetchContacts([contact])
    navigationController?.popViewControllerAnimated(true)
}

}

0 个答案:

没有答案