Iphone ABPeoplePickerNavigationController在IOS 7中崩溃

Iphone ABPeoplePickerNavigationController在IOS 7中崩溃,iphone,objective-c,ios7,Iphone,Objective C,Ios7,我对IOS 7中的ABPeoplePickerNavigationController有以下错误 *** -[ABPeoplePickerNavigationController respondsToSelector:]: message sent to deallocated instance 0x9b4b050 在IOS 6上工作正常,但在IOS 7中,如果启用了僵尸而没有僵尸,则会出现此错误 Thread 1: EXC_BAD_ACCESS(code=2,address=0x0)

我对IOS 7中的ABPeoplePickerNavigationController有以下错误

*** -[ABPeoplePickerNavigationController respondsToSelector:]: message sent to deallocated instance 0x9b4b050  
在IOS 6上工作正常,但在IOS 7中,如果启用了僵尸而没有僵尸,则会出现此错误

Thread 1: EXC_BAD_ACCESS(code=2,address=0x0)    
然后我启用僵尸
这是我的密码

 - (void)viewDidLoad
 {  
       [super viewDidLoad];
       self.contacts = [[NSMutableArray alloc] initWithCapacity:10];
       self.addressBook=ABAddressBookCreateWithOptions(NULL, NULL);
      [self checkAddressBookAccess];
 }     
 (void)requestAddressBookAccess
 {  
        ContactsViewController * __weak weakSelf = self;

        ABAddressBookRequestAccessWithCompletion(self.addressBook, ^(bool granted,                             CFErrorRef error)
                                         {
                                             if (granted)
                                             {
                                                 dispatch_async(dispatch_get_main_queue(), ^{
                                                     [weakSelf accessGrantedForAddressBook];

                                                 });
                                             }
                                         });
 }
    -(void)accessGrantedForAddressBook
    {      
       NSMutableArray *savedContacts=[[NSMutableArray alloc] initWithArray:[DatabaseHandler getAllContacts]];
        if (savedContacts &&savedContacts.count!=0) 

       [self.contacts addObjectsFromArray:savedContacts];
    }
   - (IBAction)popUpAddExistingContact:(id)sender {    

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    [picker setDelegate:self];
    [self presentViewController:picker animated:YES completion:nil];

 }
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{


NSString *viewControllerDesc=[viewController description];
NSString *t_st = @"ABContactViewController";
NSRange rang =[viewControllerDesc rangeOfString:t_st options:NSCaseInsensitiveSearch];

if (rang.length == [t_st length])
{
    navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(addPerson:)];
}
else if([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]] && [viewController isKindOfClass:[ABPersonViewController class]])
{
    ABPersonViewController *DVC=(ABPersonViewController*)viewController;
    self.currentPerson=DVC.displayedPerson;
    navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(addPerson:)];

}
else{
    navigationController.topViewController.navigationItem.rightBarButtonItem = nil;
}

navigationController.topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
}
-(IBAction)addPerson:(id)sender{

if (self.currentPerson!=NULL)
{
    CFStringRef firstName;
    int recordID;
    firstName = ABRecordCopyValue(self.currentPerson, kABPersonFirstNameProperty);
    recordID = ABRecordGetRecordID(self.currentPerson);
    MyContact *contact=[[MyContact alloc] init];
    contact.Name=(__bridge NSString *)(firstName);
    contact.contactID=[NSString stringWithFormat:@"%i",recordID];

    contact.phones=[[NSMutableArray alloc] init];
    ABMultiValueRef phones = ABRecordCopyValue(self.currentPerson, kABPersonPhoneProperty);
    for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
    {
        CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);
        CFStringRef locLabel = ABMultiValueCopyLabelAtIndex(phones, j);
        NSString *phoneNumber = (__bridge NSString *)phoneNumberRef;

        [contact.phones addObject:phoneNumber];

        CFRelease(phoneNumberRef);
        CFRelease(locLabel);
    }


    CFRelease(firstName);
    //CFRelease(lastName);
}
//[self dismissModalViewControllerAnimated:YES];

[self dismissViewControllerAnimated:YES completion:^(void ){

    [self.popUpContactView removeFromSuperview];

}];
我认为这是因为创建的视图控制器没有保留,
调用[self-addChildViewController:picker]或为其保留一个“强”引用

尝试将peopleViewController委托设置为零,然后在一段时间内取消并禁用此操作的第二个可能调用(如用户多次按下按钮)。假设您有对ABPeoplePickerNavigationController实例的引用。像self.addressbook这样的名字

然后在解散PeoplePickerNavigationController集合之前

self.adressBook.peoplePickerDelegate = nil
self.adressBook.delegate = nil;

并确保在解散后,您没有调用您的peoplePickerNavigationController引用,或者您对该实例的引用为弱,notassigntype.

我已经尝试过将ABPeoplePickerNavigationController作为我的类的属性,但它对我不起作用……我还在调用方法,以便在CFREASE on firstName之前将联系人发布到服务器上,同时在本机联系人中添加我的特殊标签和电话号码
- (IBAction)popUpAddExistingContact:(id)sender {    

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[picker setDelegate:self];
[self presentViewController:picker animated:YES completion:nil];

}
self.adressBook.peoplePickerDelegate = nil
self.adressBook.delegate = nil;