0

ABPeoplePickerNavigationControllerがあり、連絡先ページ(画像を参照)から連絡先リストに[戻る]ボタンを追加したいと思います。

ここに画像の説明を入力してください

私はそれを見つけて修正しました-必要な人のための答えは私の答えのコードにあります。

4

1 に答える 1

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];
}
于 2012-10-21T17:15:43.513 に答える