iOSS系统分享
2016-04-25 21:41
561 查看
#import "ViewController.h"
#import <Social/Social.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
//
不能再viewDidLoad进行模态视图的弹出
//Warning: Attempt to present <SLComposeViewController: 0x7f9fcb823180> on <ViewController: 0x7f9fca6a1b60> whose view is not in the window hierarchy!
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//1. 判断分享类型是否可用
if (![SLComposeViewController
isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
NSLog(@"请先到设置中添加新浪微博账号");
return;
}
//2.
创建分享控制器
SLComposeViewController *composeVC = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
//
设置预设值
//2.1
文字
//二进制 1 10
[composeVC setInitialText:@"这个世界上有10种人,
一种是懂二进制的,
一种是不懂二进制的"];
//2.2
图片
[composeVC addImage:[UIImage
imageNamed:@"dog"]];
//2.3
网址
[composeVC addURL:[NSURL
URLWithString:@"https://www.baidu.com"]];
//3.
弹出分享控制器
[self presentViewController:composeVC animated:YES completion:nil];
}
@end
#import <Social/Social.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
//
不能再viewDidLoad进行模态视图的弹出
//Warning: Attempt to present <SLComposeViewController: 0x7f9fcb823180> on <ViewController: 0x7f9fca6a1b60> whose view is not in the window hierarchy!
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//1. 判断分享类型是否可用
if (![SLComposeViewController
isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
NSLog(@"请先到设置中添加新浪微博账号");
return;
}
//2.
创建分享控制器
SLComposeViewController *composeVC = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
//
设置预设值
//2.1
文字
//二进制 1 10
[composeVC setInitialText:@"这个世界上有10种人,
一种是懂二进制的,
一种是不懂二进制的"];
//2.2
图片
[composeVC addImage:[UIImage
imageNamed:@"dog"]];
//2.3
网址
[composeVC addURL:[NSURL
URLWithString:@"https://www.baidu.com"]];
//3.
弹出分享控制器
[self presentViewController:composeVC animated:YES completion:nil];
}
@end
相关文章推荐
- iOS动画解析
- ios中isa指针
- iOS调试证书制作。。。
- cin/cou效率太慢?试一下 ios::sync_with_stdio(false);
- 《Motion Design for iOS》(二)
- iOS设计模式
- iOS边练边学--多线程练习的多图片下载 以及 使用第三方框架(SDWebImage)的多图片下载
- iOS边练边学--iOS中的(ARC下)单粒模式(GCD实现)
- [译] 盘点 iOS 开发者必看的 105 个全球最佳博客 - 分享自@开发者头条
- iOS实现TableView中Cell出现时弹出动画
- iOS控制屏幕旋转
- 使用fastlane实现iOS持续集成
- iOS Class Prefix自定义类,文件前缀
- iOS工程里添加C文件造成的编译错误
- iOS启动动画
- iOS调用打电话功能
- ios基础知识整理1
- iOS开发:提取MP3文件中的信息
- BOMStream BOMStreamWithFileAndSys
- [iOS适配-- launchImage]