How to display the default iOS 6 share action sheet with available share options?

后端 未结 2 1411
难免孤独
难免孤独 2020-11-30 17:20

Some apps show a default action sheet in iOS 6 with sharing options.

Social Framework only has two classes, one for composing and one for request.

What I fo

2条回答
  •  失恋的感觉
    2020-11-30 17:46

    Add this to use the UIActivityViewController.

    -(IBAction)shareButtonPressed:(id)sender {
    
        NSLog(@"shareButton pressed");
    
        NSString *texttoshare = _txt; //this is your text string to share
        UIImage *imagetoshare = _img; //this is your image to share
        NSArray *activityItems = @[texttoshare, imagetoshare];    
        UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
        activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint];
        [self presentViewController:activityVC animated:TRUE completion:nil];
    }
    

提交回复
热议问题