gpt4 book ai didi

ios - 显示 ABPersonViewController 的这段代码有什么问题?

转载 作者:行者123 更新时间:2023-11-29 03:35:29 24 4
gpt4 key购买 nike

-(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 动画:YES]之后;

我得到

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 是什么类或者为什么它是错误的。

最佳答案

我认为您尝试使用的属性有误。而是尝试这个:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AddressBookUI/AddressBookUI.h>

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

- (void) displayContactInfo: (ABRecordRef)person;

@end

委托(delegate)的实现(PersonViewController.m):

#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

关于ios - 显示 ABPersonViewController 的这段代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19238278/

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