iphone - 取消和完成按钮在新联系人 View 中不起作用

标签 iphone objective-c ios

我正在尝试在我的应用程序中集成新的联系人控件。这是我的代码:

- (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];

}

它会弹出新的联系人 View ,但是当我单击 时取消 完成按钮没有任何 react 。
谁能帮我?

提前致谢!

最佳答案

//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];
}

关于iphone - 取消和完成按钮在新联系人 View 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4222128/

相关文章:

ios - 如何处理语音识别中的同音字?

ios - UIPopoverPresentationController 始终显示全屏模式弹出窗口

iphone - 在 Iphone 中调整图像大小

iphone - 如何知道捏合手势何时完成(UIGestureRecognizer)

iphone - RPG游戏循环和类结构(适用于iPhone的cocos2D)

iphone - 从 UIViewController 绘制一条线

ios - 如何从 PHAsset 获取图像 URL?是否可以使用 PHAsset URL 将图像保存到文档目录?

iphone - 如何将长 NSString 拆分为页面

ios - 为 AWS S3 生成签名 URL

iphone - 更改版本号并在 Xcode 5 中构建