// 首先初始化activityItems参数

    NSArray *activityItems = [[NSArray alloc]initWithObjects:

                              desc,url,img,nil];

    

    // 初始化一个UIActivityViewController

    UIActivityViewController *activityVC = [[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:Nil] autorelease];

    // 写一个bolck,用于completionHandler的初始化

    UIActivityViewControllerCompletionHandler myBlock = ^(NSString *activityType,BOOL completed) {

        if(completed) {

            [target performSelector:sel withObject:nil];

        } else

        {

            NSLog(@"cancled\\");

        }

        [activityVC dismissViewControllerAnimated:YES completion:Nil];

    };

    

    // 初始化completionHandler,当post结束之后(无论是done还是cancell)该blog都会被调用

    activityVC.completionHandler = myBlock;

    

    // 以模态方式展现出UIActivityViewController

    [self presentViewController:activityVC animated:YES completion:Nil];

posted on 2014-12-02 15:10  xieweiwei  阅读(268)  评论(0编辑  收藏  举报