cool hit counter ios Jump to Third Party App Document Preview_Intefrankly

ios Jump to Third Party App Document Preview


Today there is a need to download attachments from the App can be previewed, the product requirements are simple to achieve is to jump to the third-party App preview can

Specific implementation code

- (IBAction)thirdPartAppAction:(UIButton *)sender {
    [self thirdAppPreview];
}

- (void)thirdAppPreview
{
    NSString *docPath = @"";
     // Ignore the file download part of the test network
     // Database path - sandbox path
    NSString *doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) lastObject];
    NSString *fileName = [doc stringByAppendingPathComponent:@"test.xlsx"];
    
     // Copy local data to the sandbox
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:fileName]) {
         // Get the path to the database file in the project - the source path.
        docPath = [[NSBundle mainBundle] pathForResource:@"test"ofType:@"xlsx"];
        
        NSError *error ;
        
        if ([fileManager copyItemAtPath:docPath toPath:fileName error:&error]) {
            NSLog(@"Database move successful");
        } else {
            NSLog(@" Database move failed");
        }
    }
    
     //Get the path file url
    NSURL*fileUrl = [NSURL fileURLWithPath:fileName];
    
     // Initialize the UIActivityViewController
    NSArray *activityItems = @[fileUrl];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
     //w/o appearing in active projects
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll];
    [self presentViewController:activityVC animated:YES completion:nil];
     // Callbacks after sharing
    activityVC.completionWithItemsHandler = ^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
        if (completed) {
            NSLog(@"completed");
             //Share Success
        } else  {
            NSLog(@"cancled");
             //Share Cancel
        }
    };
}

demo address https://github.com/destinyzhao/DocumentPreview

1530758958085.jpg


Recommended>>
1、Learning Data for White Guys The Big World in a Small World Network
2、YY founder has chip implanted in his body truth check
3、Largescale web applications of massive data and high concurrency solution summary one or two
4、Frontend graphic mixing how to achieve the desired effect without using float
5、2015Q4 Smart Wearable Market White Paper

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号