ABPeoplePickerNavigationController 实际执行
我的联系人列表在模拟器中完美显示。它获取电话号码并将其放入文本框中。所以我决定在我的 iPhone 上尝试一下,它实际上执行了我点击的东西。它会呼叫该号码,而不是将号码放入文本框。这是代码:
- (IBAction) adressBook: (id) sender {
// creating the picker
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
// place the delegate of the picker to the controll
picker.peoplePickerDelegate = self;
// showing the picker
[self presentModalViewController:picker animated:YES];
// releasing
[picker release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
/*
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(multi, 0);
//[self dismissModalViewControllerAnimated:YES];
*/
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
NSLog(@"inbool");
ABMultiValueRef phonePro = ABRecordCopyValue(person, property);
int idx = ABMultiValueGetIndexForIdentifier(phonePro, identifier);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(phonePro, idx);
[self dismissModalViewControllerAnimated:YES];
/*
ABMultiValueRef multi = ABRecordCopyValue(person, property);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(multi, identifier);
*/
return YES;
}
如果格式不正确,抱歉,这是 stackoverflow 的新手。
i have the contact list showing up perfectly in the simulator. it takes the phone number and places it in the text box. so i decided to try it on my iphone and it actually executes the thing i tap on. it calls the number instead of putting the number ito the textbox. heres the code:
- (IBAction) adressBook: (id) sender {
// creating the picker
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
// place the delegate of the picker to the controll
picker.peoplePickerDelegate = self;
// showing the picker
[self presentModalViewController:picker animated:YES];
// releasing
[picker release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
/*
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(multi, 0);
//[self dismissModalViewControllerAnimated:YES];
*/
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
NSLog(@"inbool");
ABMultiValueRef phonePro = ABRecordCopyValue(person, property);
int idx = ABMultiValueGetIndexForIdentifier(phonePro, identifier);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(phonePro, idx);
[self dismissModalViewControllerAnimated:YES];
/*
ABMultiValueRef multi = ABRecordCopyValue(person, property);
num.text = (NSString*)ABMultiValueCopyValueAtIndex(multi, identifier);
*/
return YES;
}
and sorry if not formatted correctly, new to stackoverflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
需要返回NO
,以便手机不会执行默认操作。然后您自己关闭选择器。Your
peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
needs to returnNO
so that the phone does not perform it's default action. You then close the picker yourself.