zoukankan      html  css  js  c++  java
  • 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(@"点击了发送");
      }
    };

  • 相关阅读:
    Zabbix的SNMPTrap监控配置
    Delphi 7下最小化到系统托盘
    解决来QQ消息后歌曲音量降低问题
    转载——用Mixer API函数调节控制面板的音频设置
    git branch -D 大写的D 删除分支
    gitlab+TortoiseGit中使用SSH
    SQL 高级查询
    正则表达式校验文件路径
    显示所选择文件的路径地址
    Type InvokeMember()用法简介
  • 原文地址:https://www.cnblogs.com/dashengios/p/5453545.html
Copyright © 2011-2022 走看看