• ios程序如何实现系统自带的分享


    ios系统自带的分享,支持的平台非常有限, 国内的只有 新浪微博和 腾讯微博,但是程序要求不多的话,也可以直接使用系统自带的分享,也比较简单。

    首先,需要导入系统自带的框架  #import <Social/Social.h>

    // 1.判断平台是否可用(就是手机设置里 的新浪微博 和腾讯微博 有没有账号登录)
    if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {

    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"亲,你还没有登录哦 请去设置新浪微博账户" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
    [alert show];


    return;
    }

    // 2.创建分享的控制器
    SLComposeViewController *composeVc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];

    // 2.1.添加分享的文字
    [composeVc setInitialText:@"今天天气不错"];

    // 2.2.添加一个图片
    [composeVc addImage:[UIImage imageNamed:@"xingxing"]];

    // 2.3.添加一个分享的链接
    [composeVc addURL:[NSURL URLWithString:@"www.baidu.com"]];

    // 3.弹出分享控制器
    [self presentViewController:composeVc animated:YES completion:nil];

    // 4.监听用户点击了取消还是发送
    composeVc.completionHandler = ^(SLComposeViewControllerResult result) {
    if (result == SLComposeViewControllerResultCancelled) {
        NSLog(@"点击了取消");
      } else {
      NSLog(@"点击了发送");
      }
    };

  • 相关阅读:
    Codeforces 960B(优先队列)
    “景驰科技杯”2018年华南理工大学程序设计竞赛 H-对称与反对称(逆元)
    AcWing
    POJ
    POJ
    AtCoder
    HRBUST
    CodeForces
    HYSBZ
    HDU
  • 原文地址:https://www.cnblogs.com/dashengios/p/5453545.html
Copyright © 2020-2023  润新知