美文网首页iosiOS_UIKit
UIActivityViewController系统原生分享UI

UIActivityViewController系统原生分享UI

作者: 絮语时光杨 | 来源:发表于2018-05-14 10:13 被阅读4次

    初始化
    1,activityItems要分享的数据内容

    2,applicationActivities要分享的类型
    //自定义 customActivity继承于UIActivity,创建自定义的Activity加在数组Activities中。

    • (instancetype)initWithActivityItems:(NSArray *)activityItems applicationActivities:(nullable NSArray<__kindof UIActivity *> *)applicationActivities
      NSString *textToShare = @"欢迎关注我!";
      UIImage *imageToShare = [UIImage imageNamed:@"1.png"];
      NSURL *urlToShare = [NSURL URLWithString:@"https://github.com"];
      NSArray *activityItems = @[urlToShare,textToShare,imageToShare];

    UIActivity * applicationActivities = [[UIActivity alloc] init];
    [custom prepareWithActivityItems:activityItems];
    NSArray *activities = @[applicationActivities];

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

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

    禁止分享的类型
    @property(nullable, nonatomic, copy) NSArray<UIActivityType> *excludedActivityTypes
    点击方法block
    @property(nullable, nonatomic, copy) UIActivityViewControllerCompletionWithItemsHandler completionWithItemsHandler


    UIActivity要分享的类型
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToFacebook NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToTwitter NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToWeibo NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED; // SinaWeibo
    UIKIT_EXTERN UIActivityType const UIActivityTypeMessage NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeMail NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePrint NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeCopyToPasteboard NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAssignToContact NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeSaveToCameraRoll NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAddToReadingList NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToFlickr NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToVimeo NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToTencentWeibo NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAirDrop NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeOpenInIBooks NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeMarkupAsPDF

    相关文章

      网友评论

        本文标题:UIActivityViewController系统原生分享UI

        本文链接:https://www.haomeiwen.com/subject/jfrddftx.html