zoukankan      html  css  js  c++  java
  • 通过手机其他iOS应用打开此文件

     根据所处理文档的格式,提供本地设备(InApp)能处理该格式文档的所有应用(App)。比如,demo中所处理的是pdf格式的文档,那么可以打开该文档的本地app有邮件、打印等等。仅支持ARC。

    demo: 

    https://github.com/honkmaster/TTOpenInAppActivity

    Requirements

    • As UIActivity is iOS 6 only, so is the subclass.
    • This project uses ARC. If you want to use it in a non ARC project, you must add the -fobjc-arc compiler flag to TTOpenInAppActivity.m in Target Settings > Build Phases > Compile Sources.

    Installation

    Add the TTOpenInAppActivity subfolder to your project. Required libraries: UIKit, CoreGraphics, ImageIO and MobileCoreServices.

    Usage.

    • We keep a weak referemce to the superview (UIActionSheet). In this way we dismiss the UIActionSheet ans instead display the UIDocumentInterActionController.
    • TTOpenInAppActivity needs to be initalized with the current view (iPhone & iPad) and a) a CGRect or b) a UIBarButtonItem (both only for iPad) from where it can present the UIDocumentInterActionController.
    • See example project.
    NSURL *URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"empty" ofType:@"pdf"]];
    TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andRect:((UIButton *)sender).frame];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[openInAppActivity]];
    
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        // Store reference to superview (UIActionSheet) to allow dismissal
        openInAppActivity.superViewController = activityViewController;
        // Show UIActivityViewController 
        [self presentViewController:activityViewController animated:YES completion:NULL];
    } else {
        // Create pop up
        self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
        // Store reference to superview (UIPopoverController) to allow dismissal
        openInAppActivity.superViewController = self.activityPopoverController;
        // Show UIActivityViewController in popup
        [self.activityPopoverController presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
    
  • 相关阅读:
    .Net中的加密解密
    C#集合类
    .NetFramework 1: I/O & Stream
    系列4:文件操作以及读写文件
    PetShop之表示层设计 :PetShop之表示层设计 (转)
    const和static readonly 区别
    ASP.NET经典源代码下载地址及数据库配置方法
    一个知名出版商的挫折——解读 Wrox 的历史、现在与未来(转载)
    《C++编程——数据结构与程序设计方法》程序范例:影碟店(源代码)
    ASP.NET 英语词典
  • 原文地址:https://www.cnblogs.com/niexiaobo/p/4646771.html
Copyright © 2011-2022 走看看