Modal中的ABPersonViewController

时间:2012-11-26 23:14:49

标签: objective-c cocoa abpersonviewcontroller

我想将ABPersonViewController显示为模态,而不是将其推送到导航堆栈。我有这个工作,但要保持一个完成按钮存在我必须使用NSTimer每0.25秒添加按钮,因为完成按钮可能会在视图出现时被删除,并在应用程序进入forground时始终被删除。这是一个非常蹩脚的黑客,所以我想知道是否有人有更好的主意:)

我创建了一个ABPersonViewController的子类,它添加了done按钮并在视图加载时启动了计时器,并在取消分配视图时使其无效。

以下是我的代码显示模式的内容:

- (IBAction)showContactModal:(id)sender{
    CNABPersonViewController *personViewController = [[CNABPersonViewController alloc] init];
    personViewController.displayedPerson = self.contact.record;
    personViewController.addressBook = [[CNAddressBookManager sharedManager] addressBook];
    personViewController.viewDelegate = self;
    personViewController.shouldShowLinkedPeople = YES;
    UINavigationController *navigationController =
    [[UINavigationController alloc] initWithRootViewController:personViewController];
    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;     
    [self presentViewController:navigationController animated:YES completion:nil];
}

1 个答案:

答案 0 :(得分:0)

我成功地这样做了。插入此行可在导航栏中添加按钮:

    personViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Test" style:UIBarButtonItemStylePlain target:self action:@selector(_yourAddressBookAction)];

如果这不能解决您的问题,请向我们展示您遇到问题的代码。