如何从objective-c中的CNContactPickerViewController获取生日标签?

时间:2016-04-25 05:58:51

标签: ios objective-c cncontact cncontactviewcontroller

我在swift中知道如何从CNContactPickerViewController中选择生日标签,但我在Objective-c中有点混淆

这里我使用的代码如下:在Objective-c

如何在“didSelectContactProperty”方法中选择生日标签。你能帮帮我吗...

-(void)presentContacts {
    CNContactPickerViewController *picker = [[CNContactPickerViewController alloc] init];
    NSArray *propertyKeys = @[CNContactBirthdayKey, CNContactPhoneNumbersKey, CNContactGivenNameKey, CNContactFamilyNameKey, CNContactOrganizationNameKey];
    NSPredicate *enablePredicate = [NSPredicate predicateWithFormat:@"birthday != nil"];

    picker.displayedPropertyKeys = propertyKeys;
    picker.predicateForEnablingContact = enablePredicate;
    picker.delegate = self;

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

- (void)contactPickerDidCancel: (CNContactPickerViewController *) picker {
    NSLog(@"didCancel");
}

- (void)contactPicker: (CNContactPickerViewController *) picker didSelectContact: (CNContact *)contact{    
    NSLog(@"didSelectContact");
}

- (void)contactPicker: (CNContactPickerViewController *) picker didSelectContactProperty: (CNContactProperty *)contactProperty{
     NSLog(@"didSelectProperty");
}

0 个答案:

没有答案