我在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 changes with iOS8?
但从未找到答案。显然我身上的某个错误,但我无法找到它。
更新:根据要求,以下是我设置委托的方式:
self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;
并且,在@interface:
@interface TreatmentsAddEntryTVC : UITableViewController<UITextViewDelegate,ABPeoplePickerNavigationControllerDelegate>
答案 0 :(得分:0)
尝试使用此委托方法,看看它是否命中:
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person;
{
// yes the below line is deprecated as of iOS 8
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person];
}
答案 1 :(得分:0)
我讨厌回答我自己的问题,特别是当答案毫无意义,但感动时:
self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;
从didLoad到我实际想要显示选择器的方法修复了问题。我已经在SO上看到至少一个其他问题,其中注意到并讨论了这种行为:
答案 2 :(得分:0)
对于iOS 8.1的项目, 我替换了这个方法
trackdatacompvar <- within(trackdatacompvar,
{
grpA <- check_if_in_circle(points = cbind(X, Y),
x_grpA, y_grpA, rad_grpA + 115)
grpB <- check_if_in_circle(points = cbind(X, Y),
x_grpB, y_grpB, rad_grpB + 115)
grp <- ifelse(grpA, ifelse(grpB, 'D', 'A'),
ifelse(grpB, 'B', 'C'))
} )
用这个
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
}
当我选择联系人时,新方法确实出现了。