添加电话联系人查询时代码崩溃
我只能将陈列室名称添加到我的联系人中。但是当我输入代码来添加电话号码、更多详细信息时......我的代码崩溃了。任何建议将不胜感激。这是我的代码
- (IBAction)AddContact
{
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef Showroom = ABPersonCreate();
//adding contact name as showroom name
ABRecordSetValue(Showroom, kABPersonFirstNameProperty, ShowroomName.text , nil);
//adding phone number
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiPhone, p_BcardLabel.text, kABPersonPhoneMainLabel, NULL);
ABRecordSetValue(Showroom, kABPersonPhoneProperty, multiPhone,nil);
CFRelease(multiPhone);
//adding emailaddress
ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiEmail, email_BcardLabel.text, kABWorkLabel, NULL);
ABRecordSetValue(Showroom, kABPersonEmailProperty, multiEmail, @"");
CFRelease(multiEmail);
//adding URL
ABMutableMultiValueRef multiURL = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiURL, url_BcardLabel.text, kABHomeLabel, NULL);
ABRecordSetValue(Showroom, kABPersonURLProperty, multiURL, @"");
CFRelease(multiURL);
显示以下消息
[Switching to thread 11779]
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.2 (8H7)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
I am able to add only showroom name to my contacts. But when I put the code to add phone numbers, further details....my code get crash. Any suggestion would be appreciated. Here is my code
- (IBAction)AddContact
{
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef Showroom = ABPersonCreate();
//adding contact name as showroom name
ABRecordSetValue(Showroom, kABPersonFirstNameProperty, ShowroomName.text , nil);
//adding phone number
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiPhone, p_BcardLabel.text, kABPersonPhoneMainLabel, NULL);
ABRecordSetValue(Showroom, kABPersonPhoneProperty, multiPhone,nil);
CFRelease(multiPhone);
//adding emailaddress
ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiEmail, email_BcardLabel.text, kABWorkLabel, NULL);
ABRecordSetValue(Showroom, kABPersonEmailProperty, multiEmail, @"");
CFRelease(multiEmail);
//adding URL
ABMutableMultiValueRef multiURL = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiURL, url_BcardLabel.text, kABHomeLabel, NULL);
ABRecordSetValue(Showroom, kABPersonURLProperty, multiURL, @"");
CFRelease(multiURL);
Shows following message
[Switching to thread 11779]
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.2 (8H7)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想改进您的代码。我已经检查过您的代码工作正常,只需添加以下行
,如果您想使用我的代码,请检查一下。它还会将资源文件夹中名为 abc.png 的图像添加到联系人列表中。
如有任何疑问,请询问...很乐意提供帮助
If you want only to improve your code. I have checked once your code its fine working just add the following lines
And if you want to use mine check this out. It will also add an image named abc.png from your resource folder to the contact list.
for any further query just ask... Happy to help
这是您的问题 Navnath 的答案。 Apple 提供了 ABNewPersonViewController 来打开特定的添加联系人视图。在头文件中添加 ABNewPersonViewControllerDelegate。
情况 1:应用程序是基于视图的:-
情况 2:应用程序是基于导航的:-
-(IBAction)displayContactAddWindow:(id)sender{
This is the Answer to your question Navnath. Apple provides ABNewPersonViewController to open the particular add contact view.Add the ABNewPersonViewControllerDelegate in your header file.
case 1:Application is view based:-
case 2:Application is navigation based:-
-(IBAction)displayContactAddWindow:(id)sender{