1

The ABPersonViewControllerDelegate protocol requires that the method func personViewController(personViewController: ABPersonViewController!, shouldPerformDefaultActionForPerson person: ABRecord!, property: ABPropertyID, identifier: ABMultiValueIdentifier) -> Bool be implemented.

It's called whenever a user selects any piece of contact information in an ABPersonViewController, and it holds all the information necessary to describe a contact: the property and identifier parameters.

The ABPersonViewController class also contains func setHighlightedItemForProperty(_ property: ABPropertyID, withIdentifier identifier: ABMultiValueIdentifier), which highlights the piece of contact information described by its parameters.

Simply combining these two functions, I would think that if I wanted to highlight any information the user selects, it would be as simple as:

func personViewController(personViewController: ABPersonViewController!, 
shouldPerformDefaultActionForPerson person: ABRecord!, 
property: ABPropertyID, identifier: ABMultiValueIdentifier) -> Bool {

    personViewController.setHighlightedItemForProperty(property, withIdentifier: identifier)

}

This however, seems to have zero bearing, and there is no visible highlight aside from the ephemeral one which always occurs when an item of contact information is pressed on (to be clear: I want the highlight to last, at least until the user presses that item again).

EDIT: If this (i.e. the temporary highlight) is indeed the intended behavior, how can I implement or modify this function so that the highlight persists (until it's shut off). This seems especially difficult given that ABPersonViewController is unsubclassable (a word perhaps of my own invention).

Randoms
  • 2,110
  • 2
  • 20
  • 31
  • 1
    Yes, I agree, that would be reasonable expectation, but I see the same behavior you describe. It appears to only affect the highlighting of items when first presented. – Rob Aug 12 '15 at 23:44
  • @Rob thanks for the advice. If that is the designed behavior, then, any ideas on how I can implement it or modify it for a lasting highlight? – Randoms Aug 13 '15 at 00:15
  • No, I'm afraid I don't. I tried the standard tricks (`setNeedsDisplay` did nothing, `reloadData` crashed) with no luck. Sorry. I was merely confirming the behavior that you shared with us. – Rob Aug 13 '15 at 00:19
  • BTW, I checked the iOS9 ContactsUI framework, but this functionality is completely broken there as of iOS9 beta 5, so it's hard to tell. But the API is so similar to AddressBookUI that I'd wager that this UX hasn't changed. Sadly, the standard answer to questions like this is that if you need this sort of customization, you'll probably have to implement your own UI for this. – Rob Aug 13 '15 at 16:51
  • Thanks @Rob. Looks like I may have to do just that. Too bad it's unsubclassable, as one might say. – Randoms Aug 13 '15 at 17:33

0 Answers0