我有一个 ABPeoplePickerNavigationController ,我想从联系页面(看图像)添加一个BACK按钮到联系人列表。
我发现并修复了它 - 任何需要的人的答案都在我的答案的代码中。
答案 0 :(得分:0)
- (void)inviteFromAddresBook{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty],
[NSNumber numberWithInt:kABPersonEmailProperty], nil];
picker.displayedProperties = displayedItems;
// Show the picker
[self presentModalViewController:picker animated:YES];
}
#pragma mark ABPeoplePickerNavigationControllerDelegate methods
// Displays the information of a selected person
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
return YES;
}
// Does not allow users to perform default actions such as dialing a phone number, when they select a person property.
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
if (property == kABPersonPhoneProperty) {
ABMultiValueRef phone = ABRecordCopyValue(person, property);
CFStringRef selectedNumber = ABMultiValueCopyValueAtIndex(phone, identifier);
//NSLog(@"selected Number: %@",selectedNumber);
smsPicker = [[MFMessageComposeViewController alloc] init];
smsPicker.messageComposeDelegate = self;
smsPicker.recipients = [NSArray arrayWithObjects:[NSString stringWithFormat:@"%@",selectedNumber], nil];
smsPicker.body = globalParams.inviteSMS;
[[smsPicker navigationBar]setBackgroundImage:[UIImage imageNamed:@"Nav_clean"] forBarMetrics:UIBarMetricsDefault];
[smsPicker.navigationController setDelegate:self];
}
else if(property == kABPersonEmailProperty){
ABMultiValueRef email = ABRecordCopyValue(person, property);
CFStringRef emailAddress = ABMultiValueCopyValueAtIndex(email, identifier);
NSString *urlString = mailto:a@a.com?subject=New&body=TestNew;
NSURL *mailURL = [NSURL URLWithString: urlString];
[[UIApplication sharedApplication] openURL: mailURL];
}
[self dismissModalViewControllerAnimated:YES];
return NO;
}
// Dismisses the people picker and shows the application when users tap Cancel.
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker;{
[self dismissModalViewControllerAnimated:YES];
}