iOS UIWebView loading files in development

Source: Internet
Author: User
Tags pkcs12 pkcs7 rfc822 gtar

UIWebView There are two cases when loading a file in a real-world application,

1. Online preview is implemented,

2. Download to local, then view

If this is the first case:

1 nsurl *url = [Nsurl Urlwithstring:_url]; 2         Nsurlrequest *request = [[Nsurlrequest alloc] initwithurl:url]; 3         [Self.webview Loadrequest:request];

Loading the path directly is possible.

If this is the second case

1    NSData *data = [[NSData alloc] initwithcontentsoffile:_url]; 2 3         Nsurl *url = [Nsurl Fileurlwithpath:_url]; 4 5         [Self.webview loaddata:data mimetype:self. MIMEType textencodingname:@ "UTF8" Baseurl:url];

The principle is to load the local file using the encoded method

MIMEType is an extension,
Common MIME Types (generic): Hypertext Markup Language text. HTML text/htmlxml document. XML text/xmlxhtml document. XHTML application/xhtml+xml Plain text. txt text/ Plainrtf text. rtf application/rtfpdf document. PDF Application/pdfmicrosoft Word file. Word application/mswordpng image. png image/ Pnggif graphics. gif image/gifjpeg graphics. jpeg,.jpg Image/jpegau sound file. Au audio/basicmidi music file Mid,.midi audio/midi,audio/ X-midirealaudio music files. RA,. Ram audio/x-pn-realaudiompeg file. mpg,.mpeg Video/mpegavi file. avi video/x-msvideogzip file. gz Application/x-gziptar file. Tar application/x-tar arbitrary binary data application/octet-stream  more::  {". 323", "text/h323 "},{". 3gp "," VIDEO/3GPP "},{". AaB "," Application/x-authoware-bin "},{". Aam "," Application/x-authoware-map "},{". AAs " , "Application/x-authoware-seg"},{". Acx", "Application/internet-property-stream"},{". Ai", "Application/postscript "},{". AIF "," Audio/x-aiff "},{". aifc "," Audio/x-aiff "},{". Aiff "," Audio/x-aiff "},{". Als "," Audio/x-alpha5 "},{". am C "," Application/x-mpeg "},{". Ani "," Application/octet-stream "},{". apk ","Application/vnd.android.package-archive"},{". ASC", "Text/plain"},{". ASD", "Application/astound"},{". asf", "video /X-MS-ASF "},{". Asn "," Application/astound "},{". asp "," Application/x-asap "},{". Asr "," video/x-ms-asf "},{". asx "," VI DEO/X-MS-ASF "},{". Au "," audio/basic "},{". AvB "," Application/octet-stream "},{". avi "," Video/x-msvideo "},{". AWB "," a UDIO/AMR-WB "},{". Axs "," Application/olescript "},{". Bas "," Text/plain "},{". Bcpio "," Application/x-bcpio "},{". Bin ", "Application/octet-stream"},{". Bld", "Application/bld"},{". Bld2", "Application/bld2"},{". bmp", "Image/bmp"},{". bp K "," Application/octet-stream "},{". bz2 "," Application/x-bzip2 "},{". C "," Text/plain "},{". Cal "," Image/x-cals "},{". C At "," Application/vnd.ms-pkiseccat "},{". CCN "," APPLICATION/X-CNC "},{". Cco "," Application/x-cocoa "},{". CDF "," APPLICATION/X-CDF "},{". cer "," Application/x-x509-ca-cert "},{". CGI "," magnus-internal/cgi "},{". Chat "," Application /x-chat "},{". Class "," application/oCtet-stream "},{". CLP "," Application/x-msclip "},{". CMX "," IMAGE/X-CMX "},{". Co "," Application/x-cult3d-object "},{". Cod "," image/cis-cod "},{". conf "," Text/plain "},{". Cpio "," Application/x-cpio "},{". cpp "," Text/plain "},{". CPT "," AP Plication/mac-compactpro "},{". CRD "," Application/x-mscardfile "},{". CRL "," APPLICATION/PKIX-CRL "},{". Crt "," Application/x-x509-ca-cert "},{". Csh "," Application/x-csh "},{". CSM "," CHEMICAL/X-CSML "},{". Csml "," CHEMICAL/X-CSML "},{". css "," Text/css "},{". Cur "," Application/octet-stream "},{". DCM "," X-LML/X-EVM "},{". DCR "," Application/x-direc Tor "},{". Dcx "," IMAGE/X-DCX "},{". Der "," Application/x-x509-ca-cert "},{". DHTML "," text/html "},{". Dir "," Application /x-director "},{". dll "," Application/x-msdownload "},{". DMG "," Application/octet-stream "},{". DMs "," application/ Octet-stream "},{". Doc "," Application/msword "},{". docx "," application/ Vnd.openxmlformats-officedocument.wordprocessingml.document "},{". Dot "," Application/msword"},{". DVi "," Application/x-dvi "},{". DWF "," DRAWING/X-DWF "},{". dwg "," Application/x-autocad "},{". DXF "," Application /x-autocad "},{". DxR "," Application/x-director "},{". Ebk "," Application/x-expandedbook "},{". Emb "," chemical/ X-embl-dl-nucleotide "},{". Embl "," Chemical/x-embl-dl-nucleotide "},{". EPs "," Application/postscript "},{". epub "," Application/epub+zip "},{". Eri "," Image/x-eri "},{". Es "," Audio/echospeech "},{". ESL "," Audio/echospeech "},{". etc "," Application/x-earthtime "},{". Etx "," Text/x-setext "},{". Evm "," X-LML/X-EVM "},{". Evy "," Application/envoy "},{". exe " , "Application/octet-stream"},{". Fh4", "Image/x-freehand"},{". Fh5", "Image/x-freehand"},{". FHC", "Image/x-freehand "},{". Fif "," Application/fractals "},{". Flr "," X-world/x-vrml "},{". flv "," Flv-application/octet-stream "},{". FM "," a Pplication/x-maker "},{". fpx "," image/x-fpx "},{". Fvi "," Video/isivideo "},{". Gau "," Chemical/x-gaussian-input "},{". GCA "," application/x-gca-compressed "},{". GdB "," X-lml/x-gdb "},{". gif "," Image/gif "},{". GPs "," Application/x-gps "},{". Gtar "," Application/x-gtar "},{". Gz ", "Application/x-gzip"},{". H", "Text/plain"},{". HDF", "APPLICATION/X-HDF"},{". HdM", "Text/x-hdml"},{". Hdml", "text/x -hdml "},{". Hlp "," Application/winhlp "},{". hqx "," application/mac-binhex40 "},{". HTA "," Application/hta "},{". HTC "," Text/x-component "},{". htm "," text/html "},{". html "," text/html "},{". Hts "," text/html "},{". Htt "," text/webviewhtml " },{". Ice", "X-conference/x-cooltalk"},{". ico", "Image/x-icon"},{". Ief", "Image/ief"},{". IFM", "Image/gif"},{". IFS "," Image/ifs "},{". III "," Application/x-iphone "},{". Imy "," Audio/melody "},{". Ins "," Application/x-internet-signup " },{". IPs", "Application/x-ipscript"},{". IPX", "Application/x-ipix"},{". ISP", "Application/x-internet-signup"},{". It "," Audio/x-mod "},{". Itz "," Audio/x-mod "},{". IVR "," I-world/i-vrml "},{". j2k "," image/j2k "},{". Jad "," text/vnd.su N.j2me.app-descriptor "},{". Jam", "Application/x-jam"},{". Jar", "application/java-archive"},{". Java", "Text/plain"},{". Jfif", "Image/pipeg"} , {". Jnlp", "Application/x-java-jnlp-file"},{". Jpe", "Image/jpeg"},{". jpeg", "Image/jpeg"},{". jpg", "Image/jpeg"},{ ". Jpz", "Image/jpeg"},{". js", "Application/x-javascript"},{". Jwc", "APPLICATION/JWC"},{". Kjx", "APPLICATION/X-KJX" },{". Lak", "X-lml/x-lak"},{". Latex", "Application/x-latex"},{". LCC", "Application/fastman"},{". LCL", "application/ X-digitalloca "},{". LCR "," Application/x-digitalloca "},{". Lgh "," Application/lgh "},{". Lha "," application/ Octet-stream "},{". Lml "," X-lml/x-lml "},{". Lmlpack "," X-lml/x-lmlpack "},{". Log "," Text/plain "},{". Lsf "," Video/x-la -ASF "},{". LSx "," video/x-la-asf "},{". Lzh "," Application/octet-stream "},{". M13 "," Application/x-msmediaview "},{". M "," "Application/x-msmediaview"},{". M15", "Audio/x-mod"},{". m3u", "Audio/x-mpegurl"},{". M3url", "Audio/x-mpegurl" },{". m4a", "Audio/mp4a-latm"},{". M4B", "Audio/mp4a-latm"},{". m4p", "Audio/mp4a-latm"},{". M4u", "Video/vnd.mpegurl"},{". m4v", "video/x-m4v"},{". Ma1", "a Udio/ma1 "},{". Ma2 "," Audio/ma2 "},{". Ma3 "," Audio/ma3 "},{". Ma5 "," Audio/ma5 "},{". Man "," Application/x-troff-man "}, {". Map", "Magnus-internal/imagemap"},{". mbd", "Application/mbedlet"},{". MCT", "Application/x-mascot"},{". mdb", "AP Plication/x-msaccess "},{". Mdz "," Audio/x-mod "},{". Me "," Application/x-troff-me "},{". Mel "," Text/x-vmel "},{". mht ", "message/rfc822"},{". Mhtml", "message/rfc822"},{". Mi", "application/x-mif"},{". Mid", "Audio/mid"},{". Midi", "Audi O/midi "},{". MIF "," APPLICATION/X-MIF "},{". Mil "," Image/x-cals "},{". Mio "," Audio/x-mio "},{". MMF "," Application/x-sk t-lbs "},{". Mng "," Video/x-mng "},{". Mny "," Application/x-msmoney "},{". MoC "," Application/x-mocha "},{". Mocha "," Appl Ication/x-mocha "},{". MoD "," Audio/x-mod "},{". MoF "," Application/x-yumekara "},{". Mol "," Chemical/x-mdl-molfile "},{ ". Mop", "chemical/x-mopac-iNput "},{". mov "," Video/quicktime "},{". Movie "," Video/x-sgi-movie "},{". Mp2 "," Video/mpeg "},{". mp3 "," Audio/mpeg "}, {". mp4", "Video/mp4"},{". MPa", "Video/mpeg"},{". MPC", "Application/vnd.mpohun.certificate"},{". Mpe", "Video/mpeg"} , {". mpeg", "Video/mpeg"},{". mpg", "Video/mpeg"},{". Mpg4", "Video/mp4"},{". MPGA", "Audio/mpeg"},{". Mpn", "Applicat Ion/vnd.mophun.application "},{". MPP "," Application/vnd.ms-project "},{". MPs "," Application/x-mapserver "},{". Mpv2 " , "Video/mpeg"},{". MRL", "Text/x-mrml"},{". Mrm", "APPLICATION/X-MRM"},{". Ms", "Application/x-troff-ms"},{". Msg", " Application/vnd.ms-outlook "},{". MTS "," Application/metastream "},{". MTx "," Application/metastream "},{". Mtz "," Application/metastream "},{". Mvb "," Application/x-msmediaview "},{". Mzv "," Application/metastream "},{". Nar "," Application/zip "},{". Nbmp "," Image/nbmp "},{". NC "," APPLICATION/X-NETCDF "},{". Ndb "," X-lml/x-ndb "},{". Ndwn "," appli Cation/ndwn "},{". Nif "," application/x-nif"},{". Nmz "," Application/x-scream "},{". Nokia-op-logo "," Image/vnd.nok-oplogo-color "},{". Npx "," application/ X-NETFPX "},{". Nsnd "," audio/nsnd "},{". NVA "," APPLICATION/X-NEVA1 "},{". NWS "," message/rfc822 "},{". Oda "," applicatio N/oda "},{". Ogg "," Audio/ogg "},{". Oom "," Application/x-atlasmate-plugin "},{". P10 "," Application/pkcs10 "},{". P12 "," APPLICATION/X-PKCS12 "},{". p7b "," Application/x-pkcs7-certificates "},{". p7c "," Application/x-pkcs7-mime "},{". p7m " , "Application/x-pkcs7-mime"},{". p7r", "Application/x-pkcs7-certreqresp"},{". P7s", "application/x-pkcs7-signature "},{". Pac "," Audio/x-pac "},{". Pae "," Audio/x-epac "},{". Pan "," Application/x-pan "},{". PBM "," Image/x-portable-bitma P "},{". pcx "," image/x-pcx "},{". PDA "," IMAGE/X-PDA "},{". pdb "," chemical/x-pdb "},{". pdf "," Application/pdf "},{". PF R "," APPLICATION/FONT-TDPFR "},{". pfx "," APPLICATION/X-PKCS12 "},{". PGM "," Image/x-portable-graymap "},{". Pict "," Image/x-pict "},{". Pko "," application/ynd.ms-pKipko "},{". PM "," Application/x-perl "},{". PMA "," Application/x-perfmon "},{". PMC "," Application/x-perfmon "},{". PMD " , "APPLICATION/X-PMD"},{". PML", "Application/x-perfmon"},{". PMR", "Application/x-perfmon"},{". PMW", "application/ X-perfmon "},{". png "," Image/png "},{". PNM "," Image/x-portable-anymap "},{". Pnz "," Image/png "},{". Pot, "," Application /vnd.ms-powerpoint "},{". ppm "," Image/x-portable-pixmap "},{". pps "," Application/vnd.ms-powerpoint "},{". ppt "," Application/vnd.ms-powerpoint "},{". pptx "," application/ Vnd.openxmlformats-officedocument.presentationml.presentation "},{". Pqf "," Application/x-cprplayer "},{". Pqi "," Application/cprplayer "},{". PRC "," APPLICATION/X-PRC "},{". PRF "," Application/pics-rules "},{". Prop "," Text/plain "}, {". Proxy", "Application/x-ns-proxy-autoconfig"},{". PS", "Application/postscript"},{". Ptlk", "Application/listenup "},{". Pub "," Application/x-mspublisher "},{". Pvx "," Video/x-pv-pvx "},{". Qcp "," Audio/vnd.qcelp "},{". Qt "," VIdeo/quicktime "},{". Qti "," Image/x-quicktime "},{". Qtif "," Image/x-quicktime "},{". r3t "," Text/vnd.rn-realtext3d "}, {". Ra", "Audio/x-pn-realaudio"},{". Ram", "Audio/x-pn-realaudio"},{". rar", "Application/octet-stream"},{". Ras", "im Age/x-cmu-raster "},{". RC "," Text/plain "},{". RDF "," Application/rdf+xml "},{". RF "," Image/vnd.rn-realflash "},{". RGB "," Image/x-rgb "},{". Rlf "," Application/x-richlink "},{". Rm "," Audio/x-pn-realaudio "},{". Rmf "," AUDIO/X-RMF "},{". RM I "," Audio/mid "},{". Rmm "," Audio/x-pn-realaudio "},{". rmvb "," Audio/x-pn-realaudio "},{". Rnx "," application/ Vnd.rn-realplayer "},{". Roff "," Application/x-troff "},{". RP "," Image/vnd.rn-realpix "},{". rpm "," audio/ X-pn-realaudio-plugin "},{". Rt "," Text/vnd.rn-realtext "},{". Rte "," X-lml/x-gps "},{". rtf "," Application/rtf "},{". RT G "," Application/metastream "},{". Rtx "," Text/richtext "},{". RV "," Video/vnd.rn-realvideo "},{". RWC "," application/ X-rogerwilco "},{". s3m "," Audio/x-mod "},{". s3z "," audio/x-mod "},{". SCA "," Application/x-supercard "},{". ScD "," Application/x-msschedule "},{". SCT "," Text/scriptlet "},{". S DF "," Application/e-score "},{". Sea "," Application/x-stuffit "},{". Setpay "," Application/set-payment-initiation "},{ ". SetReg", "Application/set-registration-initiation"},{". SGM", "TEXT/X-SGML"},{". SGML", "TEXT/X-SGML"},{". Sh", " Application/x-sh "},{". Shar "," Application/x-shar "},{". shtml "," magnus-internal/parsed-html "},{". Shw "," Application/presentations "},{". Si6 "," Image/si6 "},{". Si7 "," Image/vnd.stiwap.sis "},{". Si9 "," image/vnd.lgtwap.sis "},{". Sis "," Application/vnd.symbian.install "},{". Sit "," Application/x-stuffit "},{". SKD "," Application/x-koan "},{ ". SKM", "Application/x-koan"},{". SKP", "Application/x-koan"},{". Skt", "Application/x-koan"},{". SLC", "application/ X-salsa "},{". SMD "," AUDIO/X-SMD "},{". Smi "," Application/smil "},{". Smil "," Application/smil "},{". SMP "," Application /studiom "},{". Smz "," Audio/x-smd "},{". snd "," AuDio/basic "},{". SPC "," Application/x-pkcs7-certificates "},{". Spl "," Application/futuresplash "},{". Spr "," Application/x-sprite "},{". Sprite "," Application/x-sprite "},{". SDP "," APPLICATION/SDP "},{". SPT "," application/ X-SPT "},{". Src "," Application/x-wais-source "},{". SST "," Application/vnd.ms-pkicertstore "},{". Stk "," application/ Hyperstudio "},{". StL "," Application/vnd.ms-pkistl "},{". stm "," text/html "},{". svg "," Image/svg+xml "},{". Sv4cpio "," Application/x-sv4cpio "},{". Sv4crc "," APPLICATION/X-SV4CRC "},{". SVF "," Image/vnd "},{". svg "," Image/svg+xml "},{". SV H "," IMAGE/SVH "},{". Svr "," X-world/x-svr "},{". SwF "," Application/x-shockwave-flash "},{". SWFL "," application/ X-shockwave-flash "},{". T "," Application/x-troff "},{". Tad "," Application/octet-stream "},{". Talk "," Text/x-speech "} , {". Tar", "Application/x-tar"},{". Taz", "Application/x-tar"},{". TBP", "Application/x-timbuktu"},{". TBT", "applicat Ion/x-timbuktu "},{". Tcl "," Application/x-tcl "},{". Tex ", "Application/x-tex"},{". Texi", "Application/x-texinfo"},{". Texinfo", "Application/x-texinfo"},{". tgz", " Application/x-compressed "},{". tHM "," Application/vnd.eri.thm "},{". tif "," Image/tiff "},{". Tiff "," Image/tiff "},{". Tki "," application/x-tkined "},{". tkined "," application/x-tkined "},{". ToC "," Application/toc "},{". Toy "," Image/toy " },{". Tr", "Application/x-troff"},{". trk", "X-lml/x-gps"},{". TRM", "Application/x-msterminal"},{". Tsi", "AUDIO/TSPL Ayer "},{". Tsp "," application/dsptype "},{". TSV "," Text/tab-separated-values "},{". Ttf "," Application/octet-stream "} , {". Ttz", "Application/t-time"},{". txt", "Text/plain"},{". Uls", "Text/iuls"},{". Ult", "Audio/x-mod"},{". Ustar", " Application/x-ustar "},{". Uu "," Application/x-uuencode "},{". Uue "," Application/x-uuencode "},{". VCD "," application/ X-cdlink "},{". vcf "," Text/x-vcard "},{". Vdo "," Video/vdo "},{". Vib "," Audio/vib "},{". Viv "," Video/vivo "},{". Vivo ", "Video/vivo"},{". Vmd", "Application/vocaLtec-media-desc "},{". VMF "," Application/vocaltec-media-file "},{". VMI "," Application/x-dreamcast-vms-info "},{". VMs "," Application/x-dreamcast-vms "},{". Vox "," Audio/voxware "},{". Vqe "," Audio/x-twinvq-plugin "},{". Vqf "," audio/ X-twinvq "},{". Vql "," Audio/x-twinvq "},{". Vre "," X-world/x-vream "},{". Vrml "," X-world/x-vrml "},{". VRT "," x-world/x- VRT "},{". Vrw "," X-world/x-vream "},{". VTs "," Workbook/formulaone "},{". wav "," Audio/x-wav "},{". Wax "," audio/x-ms-wax "},{". Wbmp "," Image/vnd.wap.wbmp "},{". WCM "," Application/vnd.ms-works "},{". wdb "," Application/vnd.ms-works "},{". W EB "," Application/vnd.xara "},{". wi "," Image/wavelet "},{". Wis "," Application/x-installshield "},{". Wks "," Application/vnd.ms-works "},{". Wm "," VIDEO/X-MS-WM "},{". wma "," audio/x-ms-wma "},{". WMD "," APPLICATION/X-MS-WMD "},{ ". Wmf", "Application/x-msmetafile"},{". WML", "TEXT/VND.WAP.WML"},{". Wmlc", "APPLICATION/VND.WAP.WMLC"},{". wmls", " Text/vnd.wap.wmlscript "},{". WMLSC "," ApplicatioN/VND.WAP.WMLSCRIPTC "},{". WMLScript "," Text/vnd.wap.wmlscript "},{". wmv "," audio/x-ms-wmv "},{". Wmx "," video/ X-ms-wmx "},{". wmz "," Application/x-ms-wmz "},{". Wpng "," Image/x-up-wpng "},{". WPs "," Application/vnd.ms-works "},{". WPT "," X-lml/x-gps "},{". Wri "," Application/x-mswrite "},{". Wrl "," X-world/x-vrml "},{". Wrz "," X-world/x-vrml "},{". ws "," Text/vnd.wap.wmlscript "},{". WSC "," APPLICATION/VND.WAP.WMLSCRIPTC "},{". WV "," Video/wavelet "},{". wvx "," video/ X-ms-wvx "},{". Wxl "," APPLICATION/X-WXL "},{". X-gzip "," Application/x-gzip "},{". Xaf "," X-world/x-vrml "},{". Xar "," AP Plication/vnd.xara "},{". XBM "," Image/x-xbitmap "},{". XDm "," APPLICATION/X-XDMA "},{". Xdma "," APPLICATION/X-XDMA "},{ ". Xdw", "Application/vnd.fujixerox.docuworks"},{". Xht", "Application/xhtml+xml"},{". Xhtm", "Application/xhtml+xml "},{". xhtml "," Application/xhtml+xml "},{". Xla "," application/vnd.ms-excel "},{". xlc "," application/vnd.ms-excel "}, {". Xll", "Application/x-excel"},{". xlm", "Application/vnd.ms-excel "},{". xls "," application/vnd.ms-excel "},{". xlsx "," application/ Vnd.openxmlformats-officedocument.spreadsheetml.sheet "},{". xlt "," application/vnd.ms-excel "},{". xlw "," Application/vnd.ms-excel "},{". XM "," Audio/x-mod "},{". xml "," Text/plain "},{". xml "," Application/xml "},[1] {". Xmz "," Audio/x-mod "},{". Xof "," X-world/x-vrml "},{". Xpi "," Application/x-xpinstall "},{". xpm "," Image/x-xpixmap "},{" . Xsit "," Text/xml "},{". Xsl "," Text/xml "},{". Xul "," Text/xul "},{". Xwd "," Image/x-xwindowdump "},{". xyz "," chemical/x -pdb "},{". Yz1 "," Application/x-yz1 "},{". Z "," application/x-compress "},[1] {". Zac "," Application/x-zaurus-zac "},{". zip "," Application/zip "},{". Json "," Application/json "}, 

iOS UIWebView loading files in development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.