我呈现的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;
}
那么,我该怎么做? 谢谢!
我知道我的应用程序将失去控制。我试图拦截财产选择,以定制打开的电子邮件。为方便起见,我可以为用户设置主题/正文。另外,如果他们选择电话号码,我希望短信应用显示出来,而不是电话应用。因此,我需要拦截它,然后调用相应的openURL。 – Georges 2009-06-05 15:25:51