我尝试将样式从蓝色水平线更改为Drop On样式,但没有找到运气。有谁知道原因。我搜索了一个早上并做了所有事情,但仍然没有运气取代那条水平线,行高亮焦点放在被放置的行上。
- (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;
}
}
答案 0 :(得分:1)
经过一番尝试,它实际上非常简单。对于任何无法在NSOutlineView中逐行高亮地替换蓝色水平线的人。将此委托添加到NSOutlineView Delegate方法:
- (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;
}
}