UIPasteboard Example – Read, Write and Share data between apps
2015-08-10 14:56
501 查看
In UIPasteboard Example, I have explained how to read data from UIPasteboard
and write data to UIPasteboard and share data between apps.
Pasteboard can be used to store Plain Text, Rich-Text, Image, Email,…etc.
Topics covered in this tutorial:
1).UIPasteboard
APIs
2).Writing
Data to General Pasteboard
3).Reading
Data to General Pasteboard
4).Writing
Data to App Pasteboard
5).Reading
Data from App Pasteboard
6).Remove
a Pasteboard
1.1 APIs for creating a Pasteboard.
generalPasteboard : method returns system board which supports general copy-paste operations.
pasteboardWithUniqueName : method is used to create a app pasteboard which is identified by a unique system generated name.
pasteboardWithName: method returns a a pasteboard identified by name. if create flag is TRUE, then pasteboard is created.
Note: Data can be shared between apps using app pasteboard.
1.2 APIs for writing data to Pasteboard.
pasteboardType : is Uniform Type Identifier Ex: kUTTypePlainText, kUTTypeText, kUTTypeJPEG,kUTTypePNG.
To get the list of system declared Uniform Type Identifiers: Click
Here
1.3 APIs for reading data from Pasteboard.
2.1 Copy Text to General Pasteboard
Text can be copied to Pasteboard using setString / setData.
2.2 Copy Image to General Pasteboard
Image can be copied to Pasteboard using setImage / setData.
Text can be read using string attribute/dataForPasteboardType.
You can use below method, to write a dictionary to App pasteboard.
By default, Pasteboard created with pasteboardWithName or pasteboardWithUniqueName are
not persistent. To make them persistent, set the persistent to TRUE.
NSKeyedArchiver is used to encode NSDictionary as NSData.
You can use below method, to read data from Pasteboard.
NSKeyedUnarchiver is used to decode NSData as NSDictionary.
Pasteboard data can be removed using method removePasteboardWithName.
and write data to UIPasteboard and share data between apps.
Pasteboard can be used to store Plain Text, Rich-Text, Image, Email,…etc.
Topics covered in this tutorial:
1).UIPasteboard
APIs
2).Writing
Data to General Pasteboard
3).Reading
Data to General Pasteboard
4).Writing
Data to App Pasteboard
5).Reading
Data from App Pasteboard
6).Remove
a Pasteboard
1.UIPASTEBOARD APIS
1.1 APIs for creating a Pasteboard.pasteboardWithUniqueName : method is used to create a app pasteboard which is identified by a unique system generated name.
pasteboardWithName: method returns a a pasteboard identified by name. if create flag is TRUE, then pasteboard is created.
Note: Data can be shared between apps using app pasteboard.
1.2 APIs for writing data to Pasteboard.
To get the list of system declared Uniform Type Identifiers: Click
Here
1.3 APIs for reading data from Pasteboard.
2.WRITING DATA TO GENERATE PASTEBOARD
2.1 Copy Text to General PasteboardText can be copied to Pasteboard using setString / setData.
Image can be copied to Pasteboard using setImage / setData.
3). READING DATA TO GENERAL PASTEBOARD
Text can be read using string attribute/dataForPasteboardType.
4). WRITING DATA TO APP PASTEBOARD
You can use below method, to write a dictionary to App pasteboard.not persistent. To make them persistent, set the persistent to TRUE.
NSKeyedArchiver is used to encode NSDictionary as NSData.
5). READING DATA FROM APP PASTEBOARD
You can use below method, to read data from Pasteboard.
6).REMOVE PASTEBOARD
Pasteboard data can be removed using method removePasteboardWithName.相关文章推荐
- Android技能杂谈——如何优雅的处理控件的点击事件
- Welcome to the Windows Bridge for iOS project preview
- iOS Date Picker控件的简单使用(点击一个input框,弹出)
- Android aapt使用小结
- 我的Android进阶之旅------>Android的ListView数据更新后,如何使最新的条目可以自动滚动到可视范围内?
- Android自定义圆角矩形
- (4.2.16) Android 跳转应用市场的应用详情页
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext
- Android注解框架AndroidAnnotations学习笔记
- android ListView奇偶行显示不同颜色
- Unity中游戏的声音管理
- iOS 使用const定义项目全局变量
- Android 内存优化总结
- app的后台接口通讯方案
- (转)android自定义控件
- 关于 appium 调用 uiautomator 中 UiScorllable 遇到的问题及分析
- iOS推送
- 【Xamarin开发 Android 系列 4】 Android 基础知识
- Unity ShaderLab< 一> 学习总结
- vlc播放流程分析