min*_*pop 8 cocoa drag-and-drop file-type objective-c
我正在尝试创建一个接受任何文件类型的拖放区域,并将其上传到服务器(使用ASIHTTPRequest).我查看了Apple提供的以下示例:
http://developer.apple.com/library/mac/#samplecode/CocoaDragAndDrop/Introduction/Intro.html
但它只涉及处理图像的拖放.如何设置拖放操作来处理任何文件类型?
谢谢.
gla*_*ish 12
有点相关,但添加这个以防它对某人有帮助:
如果您只想处理拖动到应用程序图标上的任何文件(不需要是基于文档的应用程序):
在.h:
- (void)application:(NSApplication *)sender openFiles:(NSArray *) fileNames;
Run Code Online (Sandbox Code Playgroud)
在.m:
- (void)application:(NSApplication *)sender openFiles:(NSArray *) fileNames {
NSLog(@"Files dragged on: %@", fileNames);
}
Run Code Online (Sandbox Code Playgroud)
在xxx.plist中,在CFBundleDocumentTypes下创建一个新条目:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>NSFilenamesPboardType</string>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5172 次 |
最近记录: |