0

我在我的程序中使用此功能在我的程序中显示联系人。但是,当我单击 abpersonview 中的字段时,什么也没有发生。

- (BOOL)personViewController:(ABPersonViewController *) personViewControllershouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
        {
            NSLog(@"IN");
                return YES;
        }

我的班级有一个 AbPersonView 的对象,下面是我的班级定义

 #import <UIKit/UIKit.h>
    #import <CoreFoundation/CoreFoundation.h>
    #import<AddressBookUI/AddressBookUI.h>




         @interface ContactTable : UIViewController<UITableViewDataSource,UISearchBarDelegate,UITableViewDelegate,ABNewPersonViewControllerDelegate,UIAlertViewDelegate,ABPersonViewControllerDelegate>

         @property  CFMutableArrayRef  filteredData;

            @property  CFArrayRef contactAdd;

            @property ABRecordRef person;

            @property ABAddressBookRef addressBook;

            @property ABPersonViewController *currentPersonView;

            @property (weak, nonatomic) IBOutlet UISearchBar *contactSearchBar;

            @property (weak, nonatomic) IBOutlet UITableView *contactTableView;

            @end

我正在使用这个 Currentpersonview 作为

 self.currentPersonView=[[ABPersonViewController alloc]initWithNibName:@"ContactTable.h" bundle:nil];

        if(isFiltered)

            self.person=CFArrayGetValueAtIndex(self.filteredData,indexPath.row);

        else

            {
            NSLog(@"%ld index:%d", CFArrayGetCount(self.contactAdd),indexPath.row);
            self.person=(ABRecordRef)CFArrayGetValueAtIndex(self.contactAdd,indexPath.row);
            }

        self.currentPersonView.displayedPerson=&(*self.person);


        self.currentPersonView.allowsEditing=YES;

        self.currentPersonView.allowsActions=YES;

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

但是当我单击 ABPersonView 时,我无法对该功能进行任何响应.....

可能是什么问题??

4

1 回答 1

0

我想你需要设置委托:

 self.currentPersonView.personViewDelegate = self;//or some other class...

并在委托类中实现对应的委托方法:

– personViewController:shouldPerformDefaultActionForPerson:property:identifier:

一定要在这个类的接口中声明。

于 2013-09-30T11:00:16.547 回答