Objective c 更改NSOutlineView上的拖动样式
我试着将样式从蓝色水平线改为Drop On样式,但没有找到运气。有人知道为什么吗。我搜索了一个上午,做了所有的事情,但仍然没有用行高亮显示焦点替换掉的行的水平线Objective c 更改NSOutlineView上的拖动样式,objective-c,cocoa,Objective C,Cocoa,我试着将样式从蓝色水平线改为Drop On样式,但没有找到运气。有人知道为什么吗。我搜索了一个上午,做了所有的事情,但仍然没有用行高亮显示焦点替换掉的行的水平线 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)targetItem proposedChildIndex:(NSInteger)inde
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)targetItem proposedChildIndex:(NSInteger)index{
BOOL canDrop = index >= 0 && targetItem;
if (canDrop) {
[outlineView setDropRow:index dropOperation:NSOutlineViewDropOnItemIndex];
return NSDragOperationCopy;
} else {
return NSDragOperationNone;
}
-(NSDragOperation)大纲视图:(NSOutlineView*)大纲视图验证操作:(id)信息建议项:(id)目标项建议的子项索引:(NSInteger)索引{
布尔坎德罗普=指数>=0&&targetItem;
如果(坎德罗普){
[outlineView setDropRow:索引dropOperation:NSOutlineView-DroponitMindex];
返回NSDRAGO操作副本;
}否则{
返回nsdragooperationne;
}
}经过一点尝试,它实际上非常简单。适用于无法替换NSOutlineView中逐行高亮显示的蓝色水平线的任何人。将此委托添加到NSOutlineView委托方法:
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)targetItem proposedChildIndex:(NSInteger)index{
BOOL canDrag = index >= 0 && targetItem;
if (canDrag) {
[outlineView setDropItem:[outlineView itemAtRow:index] dropChildIndex:NSOutlineViewDropOnItemIndex];
return NSDragOperationCopy;
} else {
return NSDragOperationNone;
}
-(NSDragOperation)大纲视图:(NSOutlineView*)大纲视图验证操作:(id)信息建议项:(id)目标项建议的子项索引:(NSInteger)索引{
BOOL canDrag=index>=0&&targetItem;
如果(坎德拉){
[outlineView setDropItem:[outlineView itemAtRow:index]dropChildIndex:NSOutlineView-DroponitIndex];
返回NSDRAGO操作副本;
}否则{
返回nsdragooperationne;
}
}