사람 선택 도구는 무엇입니까? 실제로있는 tableview의 consits '화합물보기', 2 개 버튼과 searchfield (IIRC)
대답 : 당신이 운이있어
하고 에 대한하지만 물론 당신은 몇 가지 해킹 할 적합한이 구성 요소의 밤은 :를
- (void)viewDidLoad {
//you get the internal tableview
id views = [self findSubviewsOfKind:NSClassFromString(@"ABPeoplePickerTableView") withTag:NSNotFound inView:sef.peoplePickerView];
id view = [views count] ? [views objectAtIndex:0] : nil;
//subscribe to the notification
if([view respondsToSelector:@selector(selectedRow)]) {
[[NSNotificationCenter defaultCenter] addObserverForName:NSTableViewSelectionDidChangeNotification object:view queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self peoplePickerSelectedRecordChanged:self.peoplePickerView];
}];
}
}
- (NSArray *)findSubviewsOfKind:(Class)kind withTag:(NSInteger)tag inView:(NSView*)v {
NSMutableArray *array = [NSMutableArray array];
if(kind==nil || [v isKindOfClass:kind]) {
if(tag==NSNotFound || v.tag==tag) {
[array addObject:v];
}
}
for (id subview in v.subviews) {
NSArray *vChild = [self findSubviewsOfKind:kind withTag:tag inView:subview];
[array addObjectsFromArray:vChild];
}
return array;
}
- (IBAction)peoplePickerSelectedRecordChanged:(id)sender {
NSLog(@"%@", [sender selectedRecords]);
}
답장을 보내 주셔서 감사합니다. 그러나 제공 할 친절한 코드로 무엇을해야할지 모르겠습니다. 나는 obj-c에 n00b이고, 모든 것을 말하게 될 필요가 있다고 가정한다. 현재로서는이 코드가 왜 작동하는지 알 수 없으므로이를 사용하는 방법을 모릅니다. 나는 내가 필요한 것을 알고있다. (단지 사용자가 다른 이름을 클릭 할 때마다 방아쇠를 당기는 void method) ... 당신이 나를 도울 수 있다면 고마워. –
Ok ill는 약간의 설명과 당신의 사랑하는 void method를 오늘 밤 추가한다. :)) –
은 사용하기 쉽도록 대답을 약간 편집했습니다. 'peoplePickerSelectedRecordChanged'는 항목을 선택하면 시작됩니다. –