作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我到处寻找,希望有人能给我指出正确的方向。
我只想在每次用户选择不同的记录时运行一个方法。
更大的图景(如果有替代方法)是,当用户选择记录(单击)时,该人的电话号码将被放入分段控件中。
我已经尝试过:
最佳答案
人员选择器是一个 . “复合 View ”实际上由一个表格 View 、2 个按钮和一个搜索字段 (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]);
}
关于Cocoa:ABPeoplePickerView - 如何在单击一个人时触发方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14109207/
我到处寻找,希望有人能给我指出正确的方向。 我只想在每次用户选择不同的记录时运行一个方法。 更大的图景(如果有替代方法)是,当用户选择记录(单击)时,该人的电话号码将被放入分段控件中。 我已经尝试过:
我在 Mac OS X 应用程序中使用 ABPeoplePicker。我连接了一个按钮,将所选记录更改为默认的“我”记录。 这工作正常,并且记录被选中,但是,我需要滚动表格才能看到所选的记录。 NST
我需要从我的 Cocoa 应用程序访问选定人员的电子邮件。我已将 ABPeoplePickerView 放在主窗口上,并通过 [peoplePicker selectedRecords] 获得了选定人
我是一名优秀的程序员,十分优秀!