目的:
让其他应用程序 , 查看文件时候, 弹出选择项目, 其中包含自己应用的打开方式
本应用需要设置的内容TARGETS -->Info--->Document types
名称( ALL Files)自己定义.
支持类型文件:
public.data(打开大多数文件[文件夹除外]的开发方式列表都显示,自己的应用 例如: .db, .dat , 包含public.content的全部)
public.content(打开一些简单文件时候,打开方式列表显示自己应用,例如: png,jpg,plist,文档,表格,html等)
指定支持类型:(图片为例)
按文件类型“JPEG”
由文件扩展名“。JPG”
由文件扩展名“。JPEG”
由mime类型“image / jpeg文件”
“public.jpeg”, 或者是public.image
其他类型,参照最后的文档,自己尝试修改
本应用还需要在 AppDelegate实现方法:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
/*外部文件访问本应用,会传递参数过来*/
NSLog(@"application = %@",application);
NSLog(@"url = %@",url);
NSLog(@"sourceApplication = %@",sourceApplication);
NSLog(@"annotation = %@",annotation);
}
打印结果:
//文件路径
url = file://localhost/private/var/mobile/Applications/10A6BAB7-A427-4DE5-9A67-142AD74956EC/Documents/Inbox/1.jpeg
//来源的 Bundle identifier
sourceApplication = com.lazerwalker.MWOpenInKitDemo
其余两个参数根据自己需求处理
PS:有可能你的这个应用已经安装到机器, 但是再别的应用查看文件时候的打开方式列表没有自己的应用
1.从新运行一次本应用
2.从新打开其他应用
转载请标明出处,喜欢请点赞
支持类型参考文档UTI: (谷歌翻译之后就知道大概意思了)
UTI文件类型
Description文件类型描述
Conforms to 嘿嘿,咱们需要的支持类型字段
About Uniform Type Identifiers
Uniform Type Identifiers were introduced by Apple in Mac OS 10.4 (Tiger) as a modern replacement to traditional means for identifying the type of data contained within byte streams such as disk files and the clipboard.
On the Macintosh, 4-character codes known as file types have been used traditionally for this purpose, while filename extensions were (and are still) used on platforms such as Windows and Unix. In adittion to file types and filename extensions, the Internet has introduced mime types for identifying streams of data delivered through the network.
For example, let's have a look at the different ways for identifying a JPEG image:
- by the file type 'JPEG'
- by the filename extension ".jpg"
- by the filename extension ".jpeg"
- by the mime type "image/jpeg"
With UTIs, all these different identification methods are replaced by a single string: "public.jpeg".
UTIs are plain strings, commonly formed in reverse-DNS notation. Some examples are:
- public.html
- com.adobe.pdf
- com.compuserve.gif
- public.folder
- com.microsoft.word.doc
UTIs also provide a mechanism for the classification of data types. For example, the "public.jpeg" UTI conforms to the "public.image" UTI. This mechanism can be used by applications on Mac OS X for specifying classes of accepted data types in cases such as the file selection dialogs, the pasteboard, and drag and drop.
The QDrop plug-in area fully supports this classification mechanism. For example, suppose that a QDrop plug-in area has to be configured to accept drops of image files. Instead of specifying a list of all image UTIs ("public.jpeg", "public.tiff", and so on), the "public.image" UTI can be used and the plug-in area will accept any data type that conforms to the "public.image" UTI.
The tables bellow list the majority of the UTIs defined by Mac OS 10.5 (Leopard). Note that this list is not exhastive, and that third party applications may define UTIs for their own private use and data formats. For example, 4Dv11 SQL defines "com.4d.private.text.native" and a few others for use with its pasteboard related commands.
Abstract base types
UTI | Description | Conforms to |
---|---|---|
public.item | generic base type for most things (files, directories) | |
public.content | base type for anything containing user-viewable document content (documents, pasteboard data, and document packages) | |
public.composite-content | base type for content formats supporting mixed embedded content (i.e., compound documents) | public.content |
com.apple.application | base type for Mac OS X applications, launchable items | |
public.message | base type for messages (email, IM, etc.) | |
public.contact | contact information, e.g. for a person, group, organization | |
public.archive | an archive of files and directories | |
public.disk-image | a data item mountable as a volume | public.archive |
Concrete base types
UTI | Description | Conforms to |
---|---|---|
public.data | base type for any sort of simple byte stream, including files and in-memory data | public.item |
public.directory | file system directory (includes packages AND folders) | public.item |
com.apple.resolvable | anything the Alias Manager can resolve | |
public.symlink | a symbolic link | public.item, com.apple.resolvable |
com.apple.mount-point | a volume mount point (resolvable, resolves to the root dir of a volume) | public.item, com.apple.resolvable |
com.apple.alias-file | a fully-formed alias file | public.data, com.apple.resolvable |
public.url | The bytes of a URL | public.data |
public.file-url | The text of a "file:" URL | public.url |
Text types
UTI | Description | Conforms to |
---|---|---|
public.text | base type for all text-encoded data, including text with markup (HTML, RTF, etc.) | public.data, public.content |
public.plain-text | text with no markup, unspecified encoding | public.text |
public.utf8-plain-text | plain text, UTF-8 encoding | public.plain-text |
public.utf16-external-plain-text | plain text, UTF-16 encoding, with BOM, or if BOM is not present, has "external representation" byte order (big-endian) | public.plain-text |
public.utf16-plain-text | plain text, UTF-16 encoding, native byte order, no BOM | public.plain-text |
public.rtf | Rich Text Format | public.text |
public.html | HTML, any version | public.text |
public.xml | generic XML | public.text |
public.xhtml | XHTML | public.xml |
Composite content types
UTI | Description | Conforms to |
---|---|---|
com.adobe.pdf | Adobe PDF | public.data, public.composite-content |
com.apple.rtfd | Rich Text Format Directory (RTF with content embedding, on-disk format) | com.apple.package, public.composite-content |
com.apple.flat-rtfd | Flattened RTFD (pasteboard format) | public.data, public.composite-content |
com.apple.webarchive | The WebKit webarchive format | public.data, public.composite-content |
com.adobe.postscript | PostScript | public.data, public.composite-content |
com.adobe.encapsulated-postscript | Encapsulated PostScript | com.adobe.postscript |
public.presentation | presentation | public.composite-content |
Image content types
UTI | Description | Conforms to |
---|---|---|
public.image | abstract image data | public.data, public.content |
public.jpeg | JPEG image | public.image |
public.jpeg-2000 | JPEG-2000 image | public.image |
public.tiff | TIFF image | public.image |
com.apple.pict | Quickdraw PICT format | public.image |
com.compuserve.gif | GIF image | public.image |
public.png | PNG image | public.image |
com.apple.quicktime-image | QuickTime image format | public.image |
com.apple.icns | Apple icon data | public.image |
com.microsoft.bmp | Windows bitmap | public.image |
com.microsoft.ico | Windows icon data | public.image |
public.fax | fax | public.image, public.message |
com.apple.macpaint-image | MacPaint image | public.image |
public.svg-image | scalable vector graphics (SVG) | public.image |
public.xbitmap-image | X bitmap image | public.image |
public.camera-raw-image | camera raw image | public.image |
com.adobe.photoshop-image | Adobe Photoshop document | public.image |
com.adobe.illustrator.ai-image | Adobe Illustrator document | public.image |
com.truevision.tga-image | TGA image | public.image |
com.sgi.sgi-image | Silicon Graphics image | public.image |
com.ilm.openexr-image | OpenEXR image | public.image |
com.kodak.flashpix-image | FlashPix image | public.image |
com.adobe.raw-image | Adobe raw image | public.camera-raw-image |
com.canon.crw-raw-image | Canon CRW raw image | public.camera-raw-image |
com.canon.cr2-raw-image | Canon CR2 raw image | public.camera-raw-image |
com.canon.tif-raw-image | Canon TIF raw image | public.camera-raw-image |
com.nikon.raw-image | Nikon raw image | public.camera-raw-image |
com.olympus.raw-image | Olympus raw image | public.camera-raw-image |
com.fuji.raw-image | Fuji raw image | public.camera-raw-image |
com.sony.raw-image | Sony raw image | public.camera-raw-image |
com.sony.arw-raw-image | Sony ARW raw image | public.camera-raw-image |
com.konicaminolta.raw-image | Minolta raw image | public.camera-raw-image |
com.kodak.raw-image | Kodak raw image | public.camera-raw-image |
com.panasonic.raw-image | Panasonic raw image | public.camera-raw-image |
com.pentax.raw-image | Pentax raw image | public.camera-raw-image |
com.leafamerica.raw-image | Leaf raw image | public.camera-raw-image |
com.leica.raw-image | Leica raw image | public.camera-raw-image |
com.hasselblad.fff-raw-image | Hasselblad FFF raw image | public.camera-raw-image |
com.hasselblad.3fr-raw-image | Hasselblad 3FR raw image | public.camera-raw-image |
Audiovisual content types
UTI | Description | Conforms to |
---|---|---|
public.audiovisual-content | audio and/or video content | public.data, public.content |
public.movie | A media format which may contain both video and audio. Corresponds to what users would label a "movie". | public.audiovisual-content |
public.video | pure video (no audio) | public.movie |
public.audio | pure audio (no video) | public.audiovisual-content |
com.apple.quicktime-movie | QuickTime movie | public.movie |
public.mpeg | MPEG-1 or MPEG-2 movie | public.movie |
public.mpeg-4 | MPEG-4 movie | public.movie |
public.mp3 | MP3 audio | public.audio |
public.mpeg-4-audio | MPEG-4 audio layer (.m4a) | public.mpeg-4, public.audio |
com.apple.protected-mpeg-4-audio | Apple protected MPEG4 format (.m4p, iTunes music store format) | public.audio |
public.mpeg-2-video | MPEG-2 video | public.video |
com.apple.protected-mpeg-4-video | protected MPEG-4 movie | public.movie |
public.dv-movie | DV movie | public.movie |
public.avi | AVI movie | public.movie |
public.3gpp | 3GPP movie | public.movie |
public.3gpp2 | 3GPP2 movie | public.movie |
com.microsoft.windows-media-wm | Windows media | public.movie, com.microsoft.advanced-systems-format |
com.microsoft.windows-media-wmv | Windows media | public.movie, com.microsoft.advanced-systems-format |
com.microsoft.windows-media-wmp | Windows media | public.movie, com.microsoft.advanced-systems-format |
com.microsoft.windows-media-wma | Windows media audio | public.audio, com.microsoft.advanced-systems-format |
com.real.realmedia | RealMedia | public.movie |
com.real.realaudio | RealMedia audio | public.audio |
public.ulaw-audio | uLaw audio | public.audio |
public.au-audio | AU audio | public.audio |
public.aifc-audio | AIFF-C audio | public.audio |
public.aiff-audio | AIFF audio | public.aifc-audio |
public.midi-audio | MIDI audio | public.audio |
public.downloadable-sound | downloadable sound | public.audio |
com.apple.coreaudio-format | Apple CoreAudio format | public.audio |
public.ac3-audio | AC-3 audio | public.audio |
com.digidesign.sd2-audio | Sound Designer II audio | public.audio |
com.microsoft.waveform-audio | Waveform audio | public.audio |
com.soundblaster.soundfont | SoundFont audio | public.audio |
Directory types
UTI | Description | Conforms to |
---|---|---|
public.folder | a user-browsable directory (i.e., not a package) | public.directory |
public.volume | the root folder of a volume/mount point | public.folder |
com.apple.package | a packaged directory | public.directory |
com.apple.bundle | a directory conforming to one of the CFBundle layouts | public.directory |
Application types
UTI | Description | Conforms to |
---|---|---|
com.apple.application-bundle | a bundled application | com.apple.application, com.apple.bundle, com.apple.package |
com.apple.application-file | a single-file Carbon/Classic application | com.apple.application, public.data |
Contact types
UTI | Description | Conforms to |
---|---|---|
public.vcard | VCard format | public.data, public.contact |
Archive types
UTI | Description | Conforms to |
---|---|---|
org.gnu.gnu-tar-archive | GNU tar archive | public.data, public.archive |
public.tar-archive | tar archive | org.gnu.gnu-tar-archive |
org.gnu.gnu-zip-archive | GZip archive | public.data, public.archive |
org.gnu.gnu-zip-tar-archive | gzip tar archive | org.gnu.gnu-zip-archive |
public.bzip2-archive | Bzip2 archive | public.data, public.archive |
public.tar-bzip2-archive | Bzip2 compressed tar archive | public.bzip2-archive |
com.apple.binhex-archive | BinHex archive | public.data, public.archive |
com.apple.macbinary-archive | MacBinary archive | public.data, public.archive |
com.allume.stuffit-archive | Stuffit archive | public.data, public.archive |
public.zip-archive | Zip archive | com.pkware.zip-archive |
com.pkware.zip-archive | PKZip archive | public.zip-archive |
MS Office types
UTI | Description | Conforms to |
---|---|---|
com.microsoft.word.doc | Microsoft Word document | public.data, public.composite-content |
com.microsoft.excel.xls | Microsoft Excel workbook | public.data, public.composite-content |
com.microsoft.powerpoint.ppt | Microsoft PowerPoint presentation | public.data, public.presentation |
com.microsoft.word.wordml | Microsoft Word 2003 XML document | public.xml, public.composite-content |
iWork types
UTI | Description | Conforms to |
---|---|---|
com.apple.keynote.key | Keynote document | com.apple.package, public.presentation |
com.apple.iWork.Keynote.key | Keynote document | com.apple.package, public.presentation, com.apple.keynote.key |
com.apple.keynote.kth | Keynote document | com.apple.package, public.presentation |
com.apple.iWork.Keynote.kth | Keynote theme | com.apple.package, public.composite-content, com.apple.keynote.kth |
Office open xml
UTI | Description | Conforms to |
---|---|---|
org.openxmlformats.openxml | Office Open XML | public.zip-archive |
org.openxmlformats.wordprocessingml.document | Office Open XML word processing document | org.openxmlformats.openxml, public.composite-content |
org.openxmlformats.wordprocessingml.document.macroenabled | Office Open XML word processing document (macros enabled) | org.openxmlformats.openxml, public.composite-content, public.executable |
org.openxmlformats.wordprocessingml.template | Office Open XML word processing template | org.openxmlformats.openxml, public.composite-content |
org.openxmlformats.wordprocessingml.template.macroenabled | Office Open XML word processing template (macros enabled) | org.openxmlformats.openxml, public.composite-content, public.executable |
org.openxmlformats.spreadsheetml.sheet | Office Open XML spreadsheet | org.openxmlformats.openxml, public.composite-content |
org.openxmlformats.spreadsheetml.sheet.macroenabled | Office Open XML spreadsheet (macros enabled) | org.openxmlformats.openxml, public.composite-content, public.executable |
org.openxmlformats.spreadsheetml.template | Office Open XML spreadsheet template | org.openxmlformats.openxml, public.composite-content |
org.openxmlformats.spreadsheetml.template.macroenabled | Office Open XML spreadsheet template (macros enabled) | org.openxmlformats.openxml, public.composite-content, public.executable |
org.openxmlformats.presentationml.presentation | Office Open XML presentation | org.openxmlformats.openxml, public.presentation |
org.openxmlformats.presentationml.presentation.macroenabled | Office Open XML presentation (macros enabled) | org.openxmlformats.openxml, public.presentation, public.executable |
org.openxmlformats.presentationml.slideshow | Office Open XML slide show | org.openxmlformats.openxml, public.presentation |
org.openxmlformats.presentationml.slideshow.macroenabled | Office Open XML slide show (macros enabled) | org.openxmlformats.openxml, public.presentation, public.executable |
org.openxmlformats.presentationml.template | Office Open XML presentation template | org.openxmlformats.openxml, public.presentation |
org.openxmlformats.presentationml.template.macroenabled | Office Open XML presentation template (macros enabled) | org.openxmlformats.openxml, public.presentation, public.executable |
OASIS Open Document Format
UTI | Description | Conforms to |
---|---|---|
org.oasis-open.opendocument | Open Document | public.zip-archive |
org.oasis-open.opendocument.text | Open Document text | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.text-template | Open Document text template | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.graphics | Open Document graphics | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.graphics-template | Open Document graphics template | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.presentation | Open Document presentation | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.presentation-template | Open Document presentation template | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.spreadsheet | Open Document spreadsheet | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.spreadsheet-template | Open Document spreadsheet template | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.chart | Open Document chart | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.chart-template | Open Document chart template | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.image | Open Document image | org.oasis-open.opendocument, public.image |
org.oasis-open.opendocument.image-template | Open Document image template | org.oasis-open.opendocument, public.image |
org.oasis-open.opendocument.formula | Open Document formula | org.oasis-open.opendocument, public.content |
org.oasis-open.opendocument.formula-template | Open Document formula template | org.oasis-open.opendocument, public.content |
org.oasis-open.opendocument.text-master | Open Document text master | org.oasis-open.opendocument, public.composite-content |
org.oasis-open.opendocument.text-web | Open Document HTML template | org.oasis-open.opendocument, public.composite-content |