문제

When i hit done in the edit mode of the person view controller it doesn't save to the address book. It goes to the previous screen and shows the new data. However in the contact app nothing changed.

 -(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{


    ABPersonViewController *
    vcPerson = [[ABPersonViewController alloc] init];
    CFErrorRef error = NULL;
    if([self.peopleProperty objectForKey:@"phone_number"]!=nil)
    {
        NSString* phoneNumber = [self.peopleProperty objectForKey:@"phone_number"];

         ABMultiValueRef multiVal = ABRecordCopyValue(person, kABPersonPhoneProperty);
        ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutableCopy(multiVal);
        ABMultiValueAddValueAndLabel(multiPhone,(__bridge CFTypeRef)(phoneNumber), kABPersonPhoneIPhoneLabel, NULL);
        ABRecordSetValue(person, kABPersonPhoneProperty, multiPhone, &error);
        CFRelease(multiPhone);
        CFRelease(multiVal);
    }


    vcPerson.allowsActions = NO;
    vcPerson.allowsEditing = YES;
    vcPerson.displayedPerson = person;
    vcPerson.personViewDelegate = self;
    [vcPerson setEditing:YES animated:NO];
    vcPerson.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStylePlain target:self action:@selector(ReturnFromPersonView:)];
    [self.navigationController setNavigationBarHidden:NO];


    [self.navigationController pushViewController:vcPerson animated:YES];



    [self dismissViewControllerAnimated:YES completion:^{

    }];
    return NO;}

Update I figured that apparently you cant change the value in displayed person before the view controller loads. It doesn't recognise that as a change in the contact once it tries to save later on.

도움이 되었습니까?

해결책

I figured that apparently you cant change the value in displayed person before the view controller loads. It doesn't recognise that as a change in the contact once it tries to save later on

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top