我希望用户能够在联系簿中添加电话号码,因此我添加了以下代码。
我的UITableView实现了ABNewPersonViewControllerDelegate,视图显示正确,并且也正确隐藏。
但是,在弹出ABNewPersonViewController之后,我的原始视图(ABNewPersonViewController所涵盖的视图)不再对触摸作出反应。
任何猜测为什么?它的UIButton对UIControlEventTouchUpInside和UILongPressGestureRecognize事件都没有反应...
- (void)prefilledAddToContactsWith:(NSString*)number
{
// Create the pre-filled properties
ABRecordRef newPerson = ABPersonCreate();
CFErrorRef error = NULL;
CFStringRef phoneNumberValue = (__bridge CFStringRef)number;
CFStringRef phoneNumberLabel = (__bridge CFStringRef)@"home";
ABMutableMultiValueRef phoneNumber = ABMultiValueCreateMutable(kABPersonPhoneProperty);
ABMultiValueAddValueAndLabel(phoneNumber, phoneNumberValue, phoneNumberLabel, NULL);
ABRecordSetValue(newPerson, kABPersonPhoneProperty, phoneNumber, NULL);
NSAssert( !error, @"Something bad happened here." );
// Create and set-up the new person view controller
ABNewPersonViewController* newPersonViewController = [[ABNewPersonViewController alloc] initWithNibName:nil bundle:nil];
[newPersonViewController setDisplayedPerson:newPerson];
[newPersonViewController setNewPersonViewDelegate:self];
[self.navigationController pushViewController:newPersonViewController animated:YES];
[self.navigationController.navigationBar setHidden:NO];
}
- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person
{
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}