Unable to dismiss CNContactViewController

前端 未结 3 2165
无人共我
无人共我 2021-01-05 03:04

I\'m trying to let the user create a new contact. While I\'ve got the screen to prompt the user to put in all his details there is no navigation bar at the top(Like there is

3条回答
  •  抹茶落季
    2021-01-05 03:39

    You have to embed contactViewController to UINavigationController and Implement Delegate Methods.

    let createNewActionHandler = {(action: UIAlertAction) -> Void in
        let newContact = CNMutableContact()
    
        let contactPicker = CNContactViewController(forNewContact: newContact)
        contactPicker.delegate = self
        let navigation = UINavigationController(rootViewController: contactPicker)
        self.presentViewController(navigation, animated: true, completion: nil)
    
    }
    
    
    //MARK: - Delegate
    
      func contactViewController(viewController: CNContactViewController, didCompleteWithContact contact: CNContact?) {
          viewController.dismissViewControllerAnimated(true, completion: nil)
      }
    
      func contactViewController(viewController: CNContactViewController, shouldPerformDefaultActionForContactProperty property: CNContactProperty) -> Bool {
          return true
      }
    

提交回复
热议问题