2013-08-07 184 views
0

上午在我的程序中使用此功能在我的程序中顯示聯繫人。但是當我點擊abpersonview中的字段沒有任何反應。處理ABPersonViewController中的點擊事件;沒有響應點擊

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

,但我不能得到關於函數的任何respose當我點擊ABPersonView .....

可能是什麼問題?

回答

0

我想你需要設置代理:

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

和實施委託類對應的委託方法:

– personViewController:shouldPerformDefaultActionForPerson:property:identifier: 

一定要在這個類的接口聲明瞭。