尽管false从中返回contactViewController:shouldPerformDefaultActionForContactProperty:,iOS 9 似乎覆盖了此设置并执行默认操作。
例如,在CNContactViewController重定向到 Apple 地图应用程序时点击联系人的地址属性。
重现步骤:
通过以下 Swift 代码为aCNContactViewController提供 a CNContact:
func showContactViewController(forContact contact: CNContact) {
let contactViewController = CNContactViewController(forContact: contact)
contactViewController.contactStore = contactStore
contactViewController.delegate = self
contactViewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(contactViewController, animated: true)
}
以编程方式false从CNContactViewControllerDelegate方法返回:
// Implement this method to determine the resulting behavior when a property is selected.
// Return false if you do not want anything to be done or if you are handling the actions yourself.
func contactViewController(viewController: CNContactViewController, shouldPerformDefaultActionForContactProperty property: CNContactProperty) -> Bool {
return false
}
在显示的CNContactViewController中,点击联系人的地址属性。
false尽管从上述委托方法返回,用户仍将被重定向到 Apple Maps 应用程序。
关于如何防止这种重定向的任何想法?