首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示ABPersonViewController的代码有什么问题?

显示ABPersonViewController的代码有什么问题?
EN

Stack Overflow用户
提问于 2013-10-08 10:50:40
回答 1查看 261关注 0票数 0
代码语言:javascript
复制
-(void) vDisplayPerson:(ABRecordRef)person
{
    ABPersonViewController *picker = [[ABPersonViewController alloc] init] ;
    picker.personViewDelegate = self;
    picker.displayedPerson = person;
    picker.displayedProperties=@[@(kABPersonPhoneProperty),@(kABPersonEmailProperty),@(kABPersonBirthdayProperty),@(kABPersonOrganizationProperty),@(kABPersonJobTitleProperty),@(kABPersonDepartmentProperty),@(kABPersonNoteProperty),@(kABPersonCreationDateProperty)];
    // Allow users to edit the person’s information
    picker.allowsEditing = YES;
    picker.allowsActions=YES;
    //[picker setValue:[NSNumber numberWithBool:YES] forKey:@"allowsDeletion"];
    [self.navigationController pushViewController:picker animated:YES];

}

在self.navigationController推送后pushViewController:picker animated:是;

我得到了

代码语言:javascript
复制
2013-10-08 09:29:37.499 Recent Contact[5804:a0b] *** Assertion failure in +[CNContact propertyForPropertyID:], /SourceCache/AddressBookUI_Sim/AddressBookUI-1553/Framework/Sources/CNUIContact/CNContact.m:855

我甚至不知道CNContact是什么类,也不知道它为什么是错误的。

EN

回答 1

Stack Overflow用户

发布于 2013-10-08 13:14:42

我认为您尝试使用的属性是错误的。相反,尝试这样做:

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AddressBookUI/AddressBookUI.h>

@interface PersonViewController : UIViewController <ABPersonViewControllerDelegate> 
{
ABPersonViewController *personController;
}

- (void) displayContactInfo: (ABRecordRef)person;

@end

委托的实现(PersonViewController.m):

代码语言:javascript
复制
#import "PersonViewController.h"

@implementation PersonViewController

- (void) viewDidLoad
{
}

 - (void) viewDidUnload
 {
[personController release];
 }

  - (void) displayContactInfo: (ABRecordRef)person
{
personController = [[ABPersonViewController alloc] init];
[personController setDisplayedPerson:person];
[personController setPersonViewDelegate:self];
[personController setAllowsEditing:NO];
personController.addressBook = ABAddressBookCreate();   

personController.displayedProperties = [NSArray arrayWithObjects:
    [NSNumber numberWithInt:kABPersonPhoneProperty], 
    nil];

[self setView:personController.view];
}

 - (BOOL) personViewController:(ABPersonViewController*)personView shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
// This is where you pass the selected contact property elsewhere in your program
[[self navigationController] dismissModalViewControllerAnimated:YES];
return NO;
}

@end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19238278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档