【问题标题】:drag and drop in PXListView is not working in the Demo App. how to fix it?PXListView 中的拖放在演示应用程序中不起作用。如何解决?
【发布时间】:2013-01-22 11:28:48
【问题描述】:

我正在使用 PXListView 并且我正在使用 PXListView 中的演示应用程序进行测试...在进行拖放时它无法正常工作...拖放无法正常工作...

我添加了以下委托方法...但仍然没有发生正确的行删除...它被重新定位回原来的行...

    - (BOOL)listView:(PXListView*)aListView writeRowsWithIndexes:(NSIndexSet*)rowIndexes toPasteboard:(NSPasteboard*)dragPasteboard
{
    // +++ Actually drag the items, not just dummy data.
    [dragPasteboard declareTypes: [NSArray arrayWithObjects: NSStringPboardType, nil] owner: self];
    [dragPasteboard setString: @"Just Testing" forType: NSStringPboardType];

    return YES;
}

- (NSDragOperation)listView:(PXListView*)aListView validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSUInteger)row
                            proposedDropHighlight:(PXListViewDropHighlight)dropHighlight;
{
    return NSDragOperationCopy;
}

- (BOOL)listView:(PXListView*)aListView acceptDrop:(id <NSDraggingInfo>)info row:(NSUInteger)row dropHighlight:(PXListViewDropHighlight)dropHighlight
{
    return NO;
}

谁能帮我解决这个问题?

感谢和问候, 穆图

【问题讨论】:

    标签: cocoa drag-and-drop nsview nsscrollview nscollectionview


    【解决方案1】:

    这是您的解决方案。您可能需要对其进行微调,但它可以完成工作。

    - (BOOL)listView:(PXListView*)aListView acceptDrop:(id <NSDraggingInfo>)info row:   (NSUInteger)row dropHighlight:(PXListViewDropHighlight)dropHighlight
    {
         NSLog(@"Accept Drop");
         NSString *temp = [_listItems objectAtIndex: [listView selectedRow]];
         [_listItems removeObjectAtIndex: [listView selectedRow]];
         [_listItems insertObject: temp atIndex: row];
         [listView reloadData];
         return NO;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 1970-01-01
      • 2013-09-30
      相关资源
      最近更新 更多