class ComplicationController: NSObject,CLKComplicationDataSource{ // MARK: - Timeline Configuration func getSupportedTimeTravelDirections(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTimeTravelDirections) -> VoID) { handler([.forward,.backward]) } func getTimelinestartDate(for complication: CLKComplication,withHandler handler: @escaPing (Date?) -> VoID) { handler(nil) } func getTimelineEndDate(for complication: CLKComplication,withHandler handler: @escaPing (Date?) -> VoID) { handler(nil) } func getPrivacyBehavior(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationPrivacyBehavior) -> VoID) { handler(.showOnLockScreen) } // MARK: - Timeline Population func getCurrentTimelineEntry(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTimelineEntry?) -> VoID) { // Call the handler with the current timeline entry handler(nil) } func getTimelineEntrIEs(for complication: CLKComplication,before date: Date,limit: Int,withHandler handler: @escaPing ([CLKComplicationTimelineEntry]?) -> VoID) { // Call the handler with the timeline entrIEs prior to the given date handler(nil) } func getTimelineEntrIEs(for complication: CLKComplication,after date: Date,withHandler handler: @escaPing ([CLKComplicationTimelineEntry]?) -> VoID) { // Call the handler with the timeline entrIEs after to the given date handler(nil) } // MARK: - Placeholder Templates func getLocalizableSampleTemplate(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTemplate?) -> VoID) { // This method will be called once per supported complication,and the results will be cached handler(nil) }}
并为Circular,Modular和Utilitarian资产添加了图像.但是当我运行Watch App时,我无法选择Watch脸的并发症.我还需要做什么?
谢谢
格雷格
解决方法 这些代码更改是必需的:func getSupportedTimeTravelDirections(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTimeTravelDirections) -> VoID){ handler([])}func getCurrentTimelineEntry(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTimelineEntry?) -> VoID){ if complication.family == .circularSmall { let template = CLKComplicationTemplateCircularSmallRingImage() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: UIImage(named: "Circular")!) let timelineEntry = CLKComplicationTimelineEntry(date: Date(),complicationTemplate: template) handler(timelineEntry) } else if complication.family == .utilitarianSmall { let template = CLKComplicationTemplateUtilitarianSmallRingImage() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: UIImage(named: "Utilitarian")!) let timelineEntry = CLKComplicationTimelineEntry(date: Date(),complicationTemplate: template) handler(timelineEntry) } else if complication.family == .modularsmall { let template = CLKComplicationTemplateModularsmallRingImage() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: UIImage(named: "Modular")!) let timelineEntry = CLKComplicationTimelineEntry(date: Date(),complicationTemplate: template) handler(timelineEntry) } else { handler(nil) }}func getLocalizableSampleTemplate(for complication: CLKComplication,withHandler handler: @escaPing (CLKComplicationTemplate?) -> VoID){ switch complication.family { case .circularSmall: let image: UIImage = UIImage(named: "Circular")! let template = CLKComplicationTemplateCircularSmallSimpleImage() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: image) handler(template) case .utilitarianSmall: let image: UIImage = UIImage(named: "Utilitarian")! let template = CLKComplicationTemplateUtilitarianSmallSquare() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: image) handler(template) case .modularsmall: let image: UIImage = UIImage(named: "Modular")! let template = CLKComplicationTemplateModularsmallSimpleImage() template.imageProvIDer = CLKImageProvIDer(onePIEceImage: image) handler(template) default: handler(nil) }}
此外,您需要在扩展中提供图像作为资产.
总结以上是内存溢出为你收集整理的swift – 启动App的WatchOS3复杂功能全部内容,希望文章能够帮你解决swift – 启动App的WatchOS3复杂功能所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)