Tôi gần như tuyệt vọng khi tìm kiếm giải pháp trong vài tuần.iPhone ABPeoplePickerNavigationController - Cách chọn hai mục nhập duy nhất của hai thuộc tính đa giá trị khác nhau của một người từ AddressBook
Vấn đề rất đơn giản:
- Qua ABPeoplePickerNavigationController (như là một ModalView), một người sẽ được chọn.
- Chỉ sau đó (ví dụ) địa chỉ Mail sẽ được hiển thị và người dùng nên chọn một địa chỉ.
- Sau khi chọn địa chỉ Thư chỉ (ví dụ:) số điện thoại sẽ được hiển thị và người dùng nên chọn một số.
Giải pháp cho đến các khía cạnh thứ ba là nổi tiếng:
- (IBAction)importFromAddressBook
{
ABPeoplePickerNavigationController* picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
[peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]]];
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
//===PROBLEM=== Now I do have a mail address and I want to have a phone number right afterwards.
//Something like this would be straightforward, but the view does not change this way:
[peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]]];
//Here misses the important code.
//And only when I also got a phone number through this or a similar method I want to call:
[peoplePicker dismissModalViewControllerAnimated:YES];
//I do not want to start default behaviour with the mailaddress and/or phone number:
return NO;
}
Cách tiếp cận đúng dường như đẩy một Xem peoplePicker tương tự trên NavigationController của ModalView, nhưng tôi không biết làm thế nào.
Nếu có ai có ý tưởng thì nó sẽ tuyệt vời!
Nếu bạn muốn xem hành vi như vậy, bạn có thể xem ứng dụng Amazon: Nếu bạn thực hiện các bước đầu tiên của đơn đặt hàng, bạn có thể chọn địa chỉ giao hàng theo cách này: Từ Danh sách liên hệ -> Chọn một người -> Chọn một địa chỉ -> Chọn một số điện thoại. Ở đó, mọi thứ (dường như) diễn ra trong chế độ xem phương thức chỉ với một hệ thống phân cấp điều hướng với một cấp độ cao hơn so với mã tiêu chuẩn được hiển thị ở trên.
Tôi rất tiếc nhưng tôi chưa trả lời! Nhận xét của bạn hướng dẫn tôi đến giải pháp gần như chính xác như một giải thưởng. Cảm ơn nhiều!! –