地址簿电话号码(+45)前缀导致崩溃!
我无法从 iPhone 地址簿获取电话号码。
当号码不包含 +45 等国家/地区代码前缀时,没有问题,但如果包含,我的应用程序就会崩溃...
这是一个已知问题吗?我找不到任何有关它的信息...
谢谢
编辑:
我得到这样的电话号码:
-(void)getContact
{
ABPeoplePickerNavigationController *pp = [[ABPeoplePickerNavigationController alloc] init];
pp.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
pp.peoplePickerDelegate = self;
[self presentModalViewController:pp animated:YES];
[pp release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
return YES;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
saveString = (NSString *)ABMultiValueCopyValueAtIndex(phoneProperty,identifier);
saveString = [saveString stringByReplacingOccurrencesOfString:@" " withString:@""];
nummerTextField.text = saveString;
}
I am having trouble getting phone numbers from the iPhone Addressbook.
There is no problem when the number do not contain a country code prefix like +45, but if it does, my app crashes...
Is this a known issue? I haven't been able to find anything about it...
Thanks
EDIT:
I get phonenumber like this:
-(void)getContact
{
ABPeoplePickerNavigationController *pp = [[ABPeoplePickerNavigationController alloc] init];
pp.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
pp.peoplePickerDelegate = self;
[self presentModalViewController:pp animated:YES];
[pp release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
return YES;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
saveString = (NSString *)ABMultiValueCopyValueAtIndex(phoneProperty,identifier);
saveString = [saveString stringByReplacingOccurrencesOfString:@" " withString:@""];
nummerTextField.text = saveString;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您如何检索您的地址簿对象,一旦检索到它,您如何处理它以从中获取号码。我使用下面显示的代码来执行您提到的相同操作,并且它可以准确地获取号码。
我确信它会对你有所帮助。
干杯
How are you retrieving your Address book object, and once it is retrieved how do you process it to fetch the number from it.I am using the below shown code to do the same what you have mentioned and it fetches the numbers accurately.
Im sure it will help you.
Cheers
这解决了我的问题。希望有人觉得它有帮助。
This solved my problem. Hope someone finds it helpful.