gpt4 book ai didi

swift - WatchKit 2 复杂文本仅在预览中显示

转载 作者:搜寻专家 更新时间:2023-11-01 06:44:00 25 4
gpt4 key购买 nike

我正在尝试为 开发一个非常简单的复杂功能2 来自简单文本提供程序的“嗨”。

我设法实现了一些奇怪的行为;单击复杂功能或从自定义表盘屏幕预览它时,我可以看到文本,但在显示表盘时看不到。看看:

watchface behaviing strangely gif

知道是什么原因造成的吗?

我的文本提供者看起来像这样

var textProvider: CLKSimpleTextProvider

override init() {

textProvider = CLKSimpleTextProvider()
textProvider.text = "Hi"
textProvider.shortText = "HI"
textProvider.tintColor = UIColor.whiteColor()
super.init()
}

我的 getPlaceholderTemplateForComplication 看起来像

func getPlaceholderTemplateForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTemplate?) -> Void) {
// This method will be called once per supported complication, and the results will be cached

switch complication.family {
case .ModularSmall:
let stemplate = CLKComplicationTemplateModularSmallSimpleText()
stemplate.tintColor = UIColor.whiteColor()
stemplate.textProvider = textProvider
handler(stemplate)
case .CircularSmall:
let stemplate = CLKComplicationTemplateCircularSmallSimpleText()
stemplate.tintColor = UIColor.whiteColor()
stemplate.textProvider = textProvider
handler(stemplate)
default:
handler(nil)
}

}

最佳答案

在自定义表盘时,Apple Watches 会调用 getPlaceholderTemplateForComplication:withHandler: 来显示占位符文本。因为你已经实现了它 - 你可以看到“嗨”。太棒了。但是当表盘显示时,它会调用另一个方法,例如:

  • getCurrentTimelineEntryForComplication:withHandler:
  • getTimelineEntriesForComplication:beforeDate:limit:withHandler:
  • getTimelineEntriesForComplication:afterDate:limit:withHandler:

而且您似乎还没有实现它们。因此,实现这些方法将解决您的问题。您可以在此 WWDC 2015 教程中找到有关这些方法的更多详细信息:https://developer.apple.com/videos/wwdc/2015/?id=209

关于swift - WatchKit 2 复杂文本仅在预览中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32443304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com