【发布时间】:2013-01-11 12:27:42
【问题描述】:
您好,我已经实现了:
- (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 子类中,当我在表格中拖动多行时,我得到:
然后当我只拖动一两行时,我得到:
似乎返回了旧的行数,然后在其上绘制了新的行数....
请问有人能解释一下吗?这是在我的项目中使用 ARC 的结果吗?
【问题讨论】:
标签: macos cocoa drag-and-drop nstableview