我有一个表示联系人的TableView。 当我单击单元格时,我想直接进入可编辑视图,而不是转到CNContactViewController并按下"编辑按钮"。 现在我有以下内容:
我想跳过第二步。这可能吗?
我使用的代码与苹果公司的代码相同:
let contacts = try contactStore.unifiedContactWithIdentifier
(contactIdentifier!, keysToFetch: toFetch)
let controller = CNContactViewController(forContact: contacts)
controller.contactStore = contactStore
controller.delegate = self
controller.editing = true
navigationController?
.pushViewController(controller, animated: true)
print(controller.editButtonItem())
} catch {
print(error)
}
编辑:或多或少,为了说明,我试图做的,与WhatsApp在他们的App中一样!谢谢!!
答案 0 :(得分:3)
你尝试过这种方法吗?
let toFetch = [CNContactViewController.descriptorForRequiredKeys()]
let contacts = try contactStore.unifiedContactWithIdentifier
(contactIdentifier!, keysToFetch: toFetch)
let contactsViewController = CNContactViewController(forNewContact: contacts)
contactsViewController.delegate = self
contactsViewController.title = "Edit contact"
contactsViewController.contactStore = contactStore
self.navigationController?.pushViewController(contactsViewController, animated: true)