好的,下面是我需要的(虽然我还没有找到真正的答案):
WebViewWebView上。我尝试过通过WebUIDelegate及其方法,甚至registerForDraggedTypes,但仍然没有成功。
有什么想法吗?有什么地方有关于如何实现这一目标的完整例子?
发布于 2014-04-09 13:50:05
我在我的申请中这么做了,以下是重点,如果你还在找,
让它接受掉到webview中。
[self registerForDraggedTypes:
[NSArray arrayWithObjects:MyPrivateTableViewDataType,NSFilenamesPboardType,nil]];输入句柄拖动以验证/验证正在拖动的项。
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
if (sourceDragMask & NSDragOperationGeneric) {
return NSDragOperationGeneric;
}
}
}
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender{
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
// Only a copy operation allowed so just copy the data
return YES;
}
else if ( [[pboard types] containsObject:NSURLPboardType] ) {
return YES;
}
return NO;
}并最终执行/完成拖放。
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender{
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
// Only a copy operation allowed so just copy the data
return YES;
}
else{
return NO;
}
} else if ( [[pboard types] containsObject:NSURLPboardType] ) {
NSURL *url = [NSURL URLFromPasteboard: pboard];
NSString *filePath= [url path];
return YES;
}
return NO;
}https://stackoverflow.com/questions/18355841
复制相似问题