gpt4 book ai didi

iphone - ABPeoplePickerNavigationController 实际执行

转载 作者:行者123 更新时间:2023-12-03 20:34:52 25 4
gpt4 key购买 nike

我的联系人列表在模拟器中完美显示。它获取电话号码并将其放入文本框中。所以我决定在我的 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 新手。

最佳答案

您的 peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier: 需要返回 NO,以便手机不会执行默认操作。然后您自己关闭选择器。

-(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);

[peoplePicker dismissModalViewControllerAnimated: YES];

return NO;
}

关于iphone - ABPeoplePickerNavigationController 实际执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com