嗨我已经实施:
- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent *)dragEvent offset:(NSPointPointer)dragImageOffset
{
NSImage *dragImage = [NSImage imageNamed:@"Drag-Icon.png"];
NSInteger numberOfItems = dragRows.count;
NSAttributedString *numbers = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%lu",numberOfItems] attributes:attributes];
[dragImage lockFocus];
NSRect numbersSurroundRect = NSMakeRect(dragImage.size.width - (numbers.size.width + 15) - strokeWidth - 5, strokeWidth, numbers.size.width + 15, boxHeight);
NSBezierPath *circle = [NSBezierPath bezierPathWithRoundedRect:numbersSurroundRect xRadius:9.0 yRadius:9.0];
[[NSColor redColor] set];
[circle fill];
[[NSColor whiteColor] set];
[circle setLineWidth:strokeWidth];
[circle stroke];
numbersSurroundRect.origin.y += ((numbersSurroundRect.size.height - numbers.size.height) + 1.75);
[numbers drawInRect:numbersSurroundRect];
[dragImage unlockFocus];
return dragImage;
}
在我的 NSTableView 子类中,当我在表中拖动多行时,我得到:
然后,当我只拖动 1 或 2 行时,我得到:
似乎返回了旧的行数,然后在其上绘制了新的行数....
任何人都可以对此有所了解吗?这是在我的项目中使用 ARC 的结果吗?