Search code examples
ioscontactspopoverpicker

CNContactPickerViewController in popover (iOS)


Is there any way to get a popover showing a Contact picker ?

I tried this (and many other variants) with no results... (this is an IBAction method in my controller that should show the popover when "sourceView" is tapped)

I always get a full screen modal presentation of the contact picker, not a popover (my tests are on ipPad simulator).

     CNContactPickerViewController  *picker = [CNContactPickerViewController new] ;
     picker.delegate                                 = self ;
     picker.popoverPresentationController.sourceView = sourceView ;
     picker.popoverPresentationController.sourceRect = sourceView.bounds ;
     picker.popoverPresentationController.permittedArrowDirections   = UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown ;

     [self presentViewController:picker
                        animated:YES
                      completion:nil] ;

Solution

  • Not specific to CNContactPickerViewController but you would need to set the view controller's modalPresentationStyle to UIModalPresentationPopover.