Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 什么';显示PersonViewController的代码有什么问题?_Ios_Objective C - Fatal编程技术网

Ios 什么';显示PersonViewController的代码有什么问题?

Ios 什么';显示PersonViewController的代码有什么问题?,ios,objective-c,Ios,Objective C,在[self.navigationController-pushViewController:picker-animated:YES]之后 我得到 -(void) vDisplayPerson:(ABRecordRef)person { ABPersonViewController *picker = [[ABPersonViewController alloc] init] ; picker.personViewDelegate = self; picker.displ

在[self.navigationController-pushViewController:picker-animated:YES]之后

我得到

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

}

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

我认为您试图使用的属性是错误的。相反,请尝试以下方法:

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

哦,我应该将addressBook分配给ABAddressBookCreate()?
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AddressBookUI/AddressBookUI.h>

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

- (void) displayContactInfo: (ABRecordRef)person;

@end
#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