关键词:自定义分享列表、自定义事件、URL Schemes、UIPasteboard
提前注意:
以免浪费时间,不涉及Share Extension
、UIActivityViewController
、UIActivity
整体思路
App1
:通过URL Schemes
+UIPasteboard
,分享到App2
。
App2
:AppDelegate
中先跳转到分享VC
,然后UIPasteboard
获取到分享的数据展示。
效果
001.gif配置
配置URL Schemes
,一个工程可以对应多个,分别用逗号隔开就好。
适配iOS10
这里主要是指UIPasteboard
变动。最新API
已经废除persistent
属性,新增UIPasteboardOption
。
UIPasteboardOption
有两个值:
UIPasteboardOptionExpirationDate
:表示到什么时间移除。
UIPasteboardOptionLocalOnly
:表示是否一直在本地,相当于之前的persistent
属性
最新存储的用法如下:
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"my" create:YES];
if (pasteboard.items.count > 0)
{
pasteboard.items = [NSArray array];
}
NSArray *items = [ShareManager getDataArrFromModel:model Pasteboard:pasteboard];
[pasteboard setItems:items options:@{UIPasteboardOptionLocalOnly:@YES}];
Demo
需要FirstDemo和SecondDemo一起运行,FirstDemo跳转到SecondDemo。欢迎指正!
demo
网友评论