我正在向用户展示一个 ABPeoplePickerNavigationController 并要求他们选择一个联系人。一旦他们选择了一个用户,我想让他们发送到消息应用程序或电子邮件应用程序,具体取决于他们选择的属性。但是,我不知道如何自定义模式选择器被解除后发生的操作。
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
if(property == kABPersonPhoneProperty){
[self dismissModalViewControllerAnimated:YES];
NSString* phoneNumber = (NSString *)ABRecordCopyValue(person, property);
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"sms:%@", phoneNumber]];
[[UIApplication sharedApplication] openURL:url];
[phoneNumber release];
return NO;
}
if(property == kABPersonEmailProperty){
[self dismissModalViewControllerAnimated:YES];
NSString* emailAddress = (NSString *)ABRecordCopyValue(person, property);
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@", emailAddress]];
[[UIApplication sharedApplication] openURL:url];
[emailAddress release];
return NO;
}
return YES;
}
那么,我该怎么做呢?谢谢!