IOS allows its App to be displayed in the list of other apps

Source: Internet
Author: User

IOS allows its App to be displayed in the list of other apps

For applications such as Baidu online storage, you can use the following applications to open files. My jpg in the red box below is an example of my work. Because no Icon is provided in the example, the default icon is displayed.

The following are the main steps and code for this example. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + CjxwPgoxoaLU2s/uxL + signature "http://www.bkjia.com/uploads/allimg/141104/0401514a5-1.png" width = "12" height = "12" alt = "view CODE on CODE">

  1. CFBundleDocumentTypes
  2. CFBundleTypeIconFiles
  3. Icon@2x.png
  4. Icon.png
  5. CFBundleTypeName
  6. Molecules Structure File
  7. CFBundleTypeRole
  8. Viewer
  9. LSHandlerRank
  10. Owner
  11. LSItemContentTypes
  12. Com.fzrong.jpg
  13. Org. gnu. gnu-zip-archive
  14. UTExportedTypeDeclarations
  15. UTTypeConformsTo
  16. Public. plain-text
  17. Public. text
  18. UTTypeDescription
  19. Molecules Structure File
  20. UTTypeIdentifier
  21. Com.fzrong.jpg
  22. UTTypeTagSpecification
  23. Public. filename-extension
  24. Jpg
  25. Public. mime-type
  26. Image/jpg
  27. This tells the system that you can open the jpg file type.


    2. When you open your app, you need to capture the file path of the Resource:

    Add the following code to Appdelegate:

    [Objc]View plaincopy
    1. -(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation
    2. {
    3. If (url! = Nil ){
    4. NSString * path = [url absoluteString];
    5. NSMutableString * string = [[NSMutableString alloc] initWithString: path];
    6. If ([path hasPrefix: @ "file: //"]) {
    7. [String replaceOccurrencesOfString: @ "file: //" withString: @ "" options: NSCaseInsensitiveSearch range: NSMakeRange (0, path. length)];
    8. }
    9. [Self. viewController openPng: string];
    10. }
    11. Return YES;
    12. }

      Remove the file: // file path header. Otherwise, the resource cannot be found.

      3. Open jgp display in your ViewController:

      [Objc]View plaincopy
      1. -(Void) openPng :( NSString *) string
      2. {
      3. UIImage * image = [[UIImage alloc] initWithContentsOfFile: string];
      4. Float width = image. size. width;
      5. Float height = image. size. height;
      6. If (length> 320 ){
      7. Height = (height/width) * 300;
      8. Length = 300;
      9. }
      10. CGRect frame = CGRectMake (0, 20, width, height );
      11. ImageView. frame = frame;
      12. ImageView. image = image;
      13. }
        The following figure shows the effect after opening:

        Html

        Http://stackoverflow.com/questions/20869815/open-file-from-local-file-system-with-default-application-ios


Related Article

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.