我呈現的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