【问题标题】:ABPeoplePickerNavigationController predicate for enabling selection of the contact with predicateForEnablingPersonABPeoplePickerNavigationController 谓词,用于启用使用 predicateForEnablingPerson 选择联系人
【发布时间】:2015-10-14 09:50:55
【问题描述】:

我有一个ABPeoplePickerNavigationController 如下

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;

我需要禁用一些从 ABPeoplePickerNavigationController 的列表视图中选择的联系人。

浏览的时候,有这样的想法

// Predicate to enable only the contacts having a mail id atleast.
picker.predicateForEnablingPerson = [NSPredicate predicateWithFormat:@"emailAddresses.@count > 0"];

所以我实现了一个如下的谓词来排除选择我的名字的联系人。

NSString *firstName = @"Kate";

// Predicate to disable selection of the contacts with the first name given.
    picker.predicateForEnablingPerson = [NSPredicate predicateWithFormat:@"firstName != %@",firstName];

不幸的是,它不起作用。

【问题讨论】:

    标签: ios objective-c abpeoplepickerview


    【解决方案1】:

    我在 ABPeoplePickerNavigationController.h 中找到了可以在谓词中使用的常量列表

    // Constants to use in predicates:
    // A LabeledValue has a 'label' property and a 'value' property.
    // A PhoneNumber has a 'stringValue' property, a 'countryCode' property, a 'formattedStringValue' property and a 'normalizedStringValue' property
    // A InstantMessageAddress has a 'username' property and a 'service' property
    // A SocialProfile has a 'username' property and a 'service' property
    // A PostalAddress has a 'street' property, a 'subLocality' property, a 'city' property, a 'subAdministrativeArea' property, a 'state' property, a 'postalCode' property, a 'country' property and a 'ISOCountryCode' property
    //
    extern NSString * const ABPersonNamePrefixProperty NS_AVAILABLE_IOS(8_0);               // "namePrefix"                 NSString
    extern NSString * const ABPersonGivenNameProperty NS_AVAILABLE_IOS(8_0);                // "givenName"                  NSString
    extern NSString * const ABPersonMiddleNameProperty NS_AVAILABLE_IOS(8_0);               // "middleName"                 NSString
    extern NSString * const ABPersonFamilyNameProperty NS_AVAILABLE_IOS(8_0);               // "familyName"                 NSString
    extern NSString * const ABPersonNameSuffixProperty NS_AVAILABLE_IOS(8_0);               // "nameSuffix"                 NSString
    extern NSString * const ABPersonPreviousFamilyNameProperty NS_AVAILABLE_IOS(8_0);       // "previousFamilyName"         NSString
    extern NSString * const ABPersonNicknameProperty NS_AVAILABLE_IOS(8_0);                 // "nickname"                   NSString
    extern NSString * const ABPersonPhoneticGivenNameProperty NS_AVAILABLE_IOS(8_0);        // "phoneticGivenName"          NSString
    extern NSString * const ABPersonPhoneticMiddleNameProperty NS_AVAILABLE_IOS(8_0);       // "phoneticMiddleName"         NSString
    extern NSString * const ABPersonPhoneticFamilyNameProperty NS_AVAILABLE_IOS(8_0);       // "phoneticFamilyName"         NSString
    extern NSString * const ABPersonOrganizationNameProperty NS_AVAILABLE_IOS(8_0);         // "organizationName"           NSString
    extern NSString * const ABPersonDepartmentNameProperty NS_AVAILABLE_IOS(8_0);           // "departmentName"             NSString
    extern NSString * const ABPersonJobTitleProperty NS_AVAILABLE_IOS(8_0);                 // "jobTitle"                   NSString
    extern NSString * const ABPersonBirthdayProperty NS_AVAILABLE_IOS(8_0);                 // "birthday"                   NSDateComponents
    extern NSString * const ABPersonNoteProperty NS_AVAILABLE_IOS(8_0);                     // "note"                       NSString
    extern NSString * const ABPersonPhoneNumbersProperty NS_AVAILABLE_IOS(8_0);             // "phoneNumbers"               array of LabeledValue with PhoneNumber values
    extern NSString * const ABPersonEmailAddressesProperty NS_AVAILABLE_IOS(8_0);           // "emailAddresses"             array of LabeledValue with NSString values
    extern NSString * const ABPersonUrlAddressesProperty NS_AVAILABLE_IOS(8_0);             // "urlAddresses"               array of LabeledValue with NSString values
    extern NSString * const ABPersonDatesProperty NS_AVAILABLE_IOS(8_0);                    // "dates"                      array of LabeledValue with NSDateComponents values
    extern NSString * const ABPersonInstantMessageAddressesProperty NS_AVAILABLE_IOS(8_0);  // "instantMessageAddresses"    array of LabeledValue with InstantMessageAddress values
    extern NSString * const ABPersonRelatedNamesProperty NS_AVAILABLE_IOS(8_0);             // "relatedNames"               array of LabeledValue with NSString values
    extern NSString * const ABPersonSocialProfilesProperty NS_AVAILABLE_IOS(8_0);           // "socialProfiles"             array of LabeledValue with SocialProfile values
    extern NSString * const ABPersonPostalAddressesProperty NS_AVAILABLE_IOS(8_0);          // "postalAddresses"            array of LabeledValue with PostalAddress values
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多