Skip to content

Instantly share code, notes, and snippets.

@hmhmsh
Created November 30, 2017 06:20
Show Gist options
  • Save hmhmsh/56a620de01aa8cccfc53b002ee3c9b51 to your computer and use it in GitHub Desktop.
Save hmhmsh/56a620de01aa8cccfc53b002ee3c9b51 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface SnsPostViewController : UIViewController
+ (void)showActionSheet:(UIViewController*)vc ActivityItems:(NSArray*)activityItems;
@end
#import "SnsPostViewController.h"
@implementation SnsPostViewController
+ (void)showActionSheet:(UIViewController*)vc ActivityItems:(NSArray*)activityItems {
UIAlertController* ac = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
ac.popoverPresentationController.sourceView = vc.view;
// 表示しない機能をリストに入れる
// ac.excludedActivityTypes = [[NSArray alloc] initWithObjects: UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypePostToWeibo, nil];
[vc presentViewController:ac animated:YES completion:nil];
}
@end
- (void)func {
NSMutableArray *activityItems = [[NSMutableArray alloc] init];
[activityItems addObject: @"初期文字"];
// [activityItems addObject: [NSURL URLWithString:@"投稿するURL"]];
[activityItems addObject: [UIImage imageNamed:@"初期画像"]];
[SnsPostViewController showActionSheet:self ActivityItems:activityItems];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment