2011-05-30 73 views
0

我使用的是人員選擇器,因此用戶可以從聯繫人中選擇一個電話號碼以在應用中使用。ABPeoplePicker撥打所選號碼

當數用戶點擊,手機應用程序打開,這個數字叫...

有沒有什麼辦法阻止呢?

回答

2

看一看shouldPerformDefaultActionForPerson:

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)aPerson 
        property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue { 
      if(property == kABPersonPhoneProperty) { 
       //save the number 
       return NO; 
      } 
     return YES; 
     } 

- 編輯 -

上述方法是用於ABPersonViewController我誤認爲ABPeoplePicker。對於ABPeoplePicker的邏輯是一樣的上面只有你會使用這個委託回調來代替:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier 
0

我只是忘了在shouldContinueAfterSelectingPerson返回NO:方法,我不知道你在哪裏得到shouldPerformDecaultActionForPerson:從,這不是授權方法之一