Watch OS 2 Complication开发教程(三)基本数据(持续连载中)
来源:互联网 发布:mac拼音切换 编辑:程序博客网 时间:2024/05/06 23:06
那么经过讲解,我们来看一看怎么实现数据的传输
首先我们先在最后面加入一个帮助函数
private func templateForWatch() ->CLKComplicationTemplate{ let template = CLKComplicationTemplateModularLargeStandardBody() template.headerImageProvider = CLKImageProvider(onePieceImage: UIImage(named: "x2")!) template.headerTextProvider = CLKSimpleTextProvider(text: "TitleHello") template.body1TextProvider = CLKSimpleTextProvider(text: "HelloWorld, the content is not blank any more") return template }
如果不明觉厉的话请看我的上一篇Blog
里面的
template.headerTextProvider = CLKSimpleTextProvider(text: "TitleHello") template.body1TextProvider = CLKSimpleTextProvider(text: "HelloWorld, the content is not blank any more")
可以在text:后面传值,只要传的是一个字符串(String)即可
那么完成了这个函数后我们找到getCurrentTimelineEntryForComplication这个函数
往里面加入以下代码
let entries = CLKComplicationTimelineEntry(date: NSDate(), complicationTemplate: templateForWatch()) handler(entries)
这是什么呢?
我们首先构造一个CLKCompliactionTimelineEntry常量,包含一个NSDate和一个Template(也就是我们的templateForWatch返回的Template)
然后把这个常量传给handler
大功告成!
PS:因为这个Complication目前没有任何的在时间改变时改变内容的操作,我们可以在getSupportedTimeTravelDirectionsForComplication函数中这样写
func getSupportedTimeTravelDirectionsForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTimeTravelDirections) -> Void) { handler([.None]) }
这样的话就不支持timeTravel啦
0 0
- Watch OS 2 Complication开发教程(三)基本数据(持续连载中)
- Watch OS 2 Complication开发教程(一)基础(持续连载中)
- Watch OS 2 Complication 开发教程 (二) (持续连载中)
- Watch OS 2 中 Taptic Engine 的开发教程
- 使用Objective-C开发AppleWatch(一)关于Complication
- Apple Watch视频教程(连载)
- Apple Watch开发和数据传输(三)
- Drupal 模块开发基本教程(三)
- AJAX实例文章教程连载(三)
- Watch OS开发笔记
- [Sparrow OS 设计文档连载(三)] Process Management
- 大话企业级Android开发(连载教程)
- Apple Watch开发(三)--WatchKit简介和Watch适配、布局
- 【教程连载】ArcGIS Runtime for Android开发教程V2.0(2)开发环境配置
- Drupal 模块开发基本教程(三)
- Apple watch 开发指南(2) 前言
- 软件技术连载(三)
- 天凉好个秋(连载三)
- PAT 01-2. Maximum Subsequence Sum (25) - Python
- Java Date20150816(上午)
- android体系结构以及源代码阅读环境搭建
- Python初学(1)
- 2.05米的绳子
- Watch OS 2 Complication开发教程(三)基本数据(持续连载中)
- 任何事都不要指望别人
- php和apache安装memcache的过程
- 独立程序员如何赚钱致富
- LaTex 参考文献引用命令
- 机房收费系统之结账
- 观察者模式
- ZOJ 3626 Treasure Hunt I (树形dp)
- vsftp服务器root账户不能用于ftp登录的解决方法