我正在尝试在我的应用中集成新的联系人控件。这是我的代码:
- (BOOL) personViewController:(ABPersonViewController*)personView shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
return YES;
}
-(IBAction)addcontact:(id)sender{
ABNewPersonViewController *picker = [[ABNewPersonViewController alloc] init];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:picker];
[self presentModalViewController:navigation animated:YES];
[picker release];
[navigation release];
}
会弹出新的联系人视图,但是当我点击取消或完成按钮时,没有任何反应。 谁能帮我?
提前致谢!
答案 0 :(得分:4)
//Make sure your VC is an <ABNewPersonViewControllerDelegate>
-(void) newPersonViewController:(ABNewPersonViewController *)newPersonView
didCompleteWithNewPerson:(ABRecordRef)person {
if (person != nil) //nil = Cancel button clicked
{
//do something
}
//iOS6
[self dismissViewControllerAnimated:YES completion:nil];
}
答案 1 :(得分:1)
您需要添加在点击取消或完成按钮时应调用的方法,并且该方法应调用[self.navigationController dismissModalViewController