[英]ios 8 : ABPeoplePickerNavigationController dismiss on implementing people picker delegate methods
[英]IOS 8 - ABPeoplePickerNavigationController - Cancel delegate method works, others do not
我在IOS 8人員選擇器委托代碼中遇到了一個奇怪的問題。 只有
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker;
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
方法被調用。 我已經審查了其他問題,並通過調用舊的IOS 7方法對選擇聯系人的IOS 8委托方法進行了重要更改。
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier: (ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}
但它從未被調用。
我在調用viewcontroller didLoad中設置委托,
而且它在ios 7中完美運行。這是一個故事板應用程序。
我在這里的評論中看到了相同的問題: ABPeoplePickerNavigationController是否隨iOS8更改?
但從未找到答案。 顯然我的某個地方有一個錯誤,但我找不到它。
更新:根據要求,這是我設置委托的方式:
self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;
並且,在@interface中:
@interface TreatmentsAddEntryTVC : UITableViewController<UITextViewDelegate,ABPeoplePickerNavigationControllerDelegate>
嘗試改用此委托方法,看看是否成功:
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person;
{
// yes the below line is deprecated as of iOS 8
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person];
}
我討厭回答我自己的問題,尤其是當答案沒有任何意義,只是動容的時候:
self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;
從didLoad到我實際要顯示選擇器的方法,可以解決此問題。 我在SO上至少看到了另一個問題,該行為在何處得到記錄和討論:
對於使用iOS 8.1的項目,我替換了此方法
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
}
有了這個
-(void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person{
}
當我選擇一個聯系人時,新方法就成功了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.