记录 总结 学习
这个项目作为自己博客 v-ios.com 的另一种展示形式
💪
记录 总结 学习
相信做过第三方分享的开发者们已经受够了第三方分享的各种埋坑文档 , 辗转各大官方申请 配置 APPKey 等繁琐的操作实在不够人性化
直到我遇到系统分享. 一切都简单了.
系统分享调用相比遇第三方分享 无需查看海量文档 不用引用大量第三方代码 快速, 安全.
#调用系统分享
UIActivityViewController *activeViewController = [[UIActivityViewController alloc]initWithActivityItems:@[@"哈哈"] applicationActivities:nil];
// 这是设置分享列表中哪些东西要隐藏掉
activeViewController.excludedActivityTypes = @[UIActivityTypeAirDrop];
[self presentViewController:activeViewController animated:YES completion:nil];
// 完成分享后的回调
activeViewController.completionWithItemsHandler = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
NSLog(@"%@ %@",activityType, returnedItems);
};
#直接调用系统分享中的某一个 比如微信!
首先导入 #import <Social/Social.h>
微信的 ServiceType ( com.tencent.xin.sharetimeline )是由直接调用系统分享原生列表时 是在成功调用系统分享列表中的调用微信完成后 在回调方法中打印出来的
activeViewController.completionWithItemsHandler = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
// NSLog(@"%@ %@",activityType, returnedItems);
// };
知道了某个分享选项的 activityType 后,就可以直接调起而不用先弹出系统分钟列表再点击了(如果需要的话)
SLComposeViewController *svc = [SLComposeViewController composeViewControllerForServiceType:@"com.tencent.xin.sharetimeline"];
SLComposeViewControllerCompletionHandler myblock = ^(SLComposeViewControllerResult result){
if(result == SLComposeViewControllerResultCancelled){
NSLog(@"cancel");
}else{
NSLog(@"done");
}
[svc dismissViewControllerAnimated:YES completion:nil];
};
svc.completionHandler = myblock;
[svc setInitialText:@"title"];
[svc addURL:[NSURL URLWithString:@"www.luoo.net"]];
[self presentViewController:svc animated:YES completion:nil];
以上是尽量精简的演示代码 想了解更多请看以下代码
/*直接调用系统微信分享的ServiceType*/
NSString *const SystemSocialType_WeiXin=@"com.tencent.xin.sharetimeline";
/*调用系统微信分享*/
+(BOOL)showSystemSocialWeiXinShare:(NSString *)title webUrl:(NSString *)weburl viewController:(UIViewController*)viewController
{
if([SLComposeViewController isAvailableForServiceType:SystemSocialType_WeiXin])
{//系统分享里有微信才行哦
if((title==nil||[title isEqualToString:@""])&&(weburl==nil||[weburl isEqualToString:@""]))
{//title 和 weburl 都为空
return NO;
}
SLComposeViewController *svc = [SLComposeViewController composeViewControllerForServiceType:SystemSocialType_WeiXin];
SLComposeViewControllerCompletionHandler myblock = ^(SLComposeViewControllerResult result){
if(result == SLComposeViewControllerResultCancelled){
NSLog(@"cancel");
}else{
NSLog(@"done");
}
[svc dismissViewControllerAnimated:YES completion:nil];
};
svc.completionHandler = myblock;
if(title)
{
[svc setInitialText:title];
}
if(weburl)
{
[svc addURL:[NSURL URLWithString:weburl]];
}
[viewController presentViewController:svc animated:YES completion:nil];
return YES;
}
return NO;
}
基于
Kevinxyg 在简书发表的文章 CocoaPods安装方法-2017
大雄不会飞 在简书发表的文章 2017最新CocoaPods安装
电脑重装了 所以又重新安装了一遍CocoaPods
主要分为三步
CocoaPods目前安装需要Ruby的版本大于2.2.2,不然会报错:Error installing pods: activesupport requires Rubyversion >= 2.2.2。目前Mac系统默认自带是2.0,所以需要升级。
以下为详细安装过程
ruby -v
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
rvm install 2.4.0
需要等待较长时间rvm list known
rvm install 2.4.0
2017最新的rubygems镜像服务由ruby-china提供 第一步需要等待
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.org/
网上教程大多是
sudo gem install -n /usr/local/bin cocoapods
pod setup
整个过程非常慢 而且不知道进度多少了
大雄不会飞 发现下面这种方式可以看到进度且速度比较快
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
sudo gem install -n /usr/local/bin cocoapods
pod repo update
验证pod是否安装成功 我们来看一下pod版本
现在是2017年7月 我这里最终安装好的为1.2.1
pod --version
如果看到了 pod 版本 恭喜✨
现在, 你可以流畅得使用 pod 来管理你的项目第三方了. 🌈
至于 pod 的使用, 以及 pod 中 swift & objc 的混合使用, 以后整理好会发布在我的博客. 我的博客地址为 V Blog ( v-ios.com ) 刚学会用django建站, 博客还比较简陋🤒
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.