App crash on use of PeoplePicker, but not in same view

前端 未结 3 1702
花落未央
花落未央 2021-01-12 19:20

Update 2, I hope this helps someone, there is a solutions at the following link: https://discussions.apple.com/thread/5498630?start=0&tstart=0 , evidently th

相关标签:
3条回答
  • 2021-01-12 19:24

    Well, there is also a bit more simple solution to this. The actual problem is in using ABPeoplePickerNavigationController as a singleton object, setting its delegate to a view controller and then dismissing the view controller. So, in my case the solution that worked is this one:

    - (void)peoplePickerNavigationControllerDidCancel:
    (ABPeoplePickerNavigationController *)peoplePicker
    {
        peoplePicker.peoplePickerDelegate = nil; // clear delegate prior to dismissing self
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }
    
    - (BOOL)peoplePickerNavigationController:
    (ABPeoplePickerNavigationController *)peoplePicker
          shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                    property:(ABPropertyID)property
                                  identifier:(ABMultiValueIdentifier)identifier
    {
        [self displayPerson:person];
        peoplePicker.peoplePickerDelegate = nil; // clear delegate prior to dismissing self
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
        return NO;
    }
    
    0 讨论(0)
  • 2021-01-12 19:35

    Thank You for the work around this issue. Your method #2 really works!!! I have the similar situation discussed in https://discussions.apple.com/thread/5498630?start=0&tstart=0 : MKMapView is placed by IB in storyboard, no code except IBOutlet. I present ABPeoplePickerController then simply cancel it by dismiss and leave this view by navigation. Then return back and get memory issue: called method barStyle of zombie UINavigationBar at address of dismissed ABPeoplePickerController. This situation happened only on iOS 7 (iPad 3rd ten and iPhone 4S) but code works fine on iOS 6 (iPhone 3GS) and only with combination with MKMapView. I test with WebView instead of MapView and all works fine. I think it is real bug in iOS 7. Kind regards Alexey

    0 讨论(0)
  • 2021-01-12 19:39

    Sorry to answer my own question, but another work around to this that requires little change is to use CF Retain to correct the over release I was experiencing. I retained the person and the peoplePicker and all was resolved. Thanks for everyone who tried to help me solve this.

    - (void)peoplePickerNavigationControllerDidCancel:
    (ABPeoplePickerNavigationController *)peoplePicker
    {
    
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
       CFRetain((__bridge CFTypeRef)(peoplePicker));
    }
    - (BOOL)peoplePickerNavigationController:
    (ABPeoplePickerNavigationController *)peoplePicker
          shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                    property:(ABPropertyID)property
                                  identifier:(ABMultiValueIdentifier)identifier
    {
        [self displayPerson:person];
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
        CFRetain(person);
        CFRetain((__bridge CFTypeRef)(peoplePicker));
        return NO;
    
    }
    
    0 讨论(0)
提交回复
热议问题