我遇到了Apple Watch的并发症问题。
我试图在并发症上显示图像和一些文本。我可以在Clock界面上选择复杂功能,但它没有显示应用标题和两行充满" - "字符。
复杂功能应该显示我的信息,但我不知道我的代码中有什么问题
以下是代码:
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)
var template: CLKComplicationTemplateModularLargeColumns?
switch complication.family {
case .modularSmall:
template = nil
case .modularLarge:
let modularLargeTemplate =
CLKComplicationTemplateModularLargeColumns()
modularLargeTemplate.row1ImageProvider =
CLKImageProvider(onePieceImage: UIImage(named: "GreenUser")!)
modularLargeTemplate.row2ImageProvider =
CLKImageProvider(onePieceImage: UIImage(named: "GreenUser")!)
modularLargeTemplate.row3ImageProvider =
CLKImageProvider(onePieceImage: UIImage(named: "GreenUser")!)
modularLargeTemplate.row1Column1TextProvider = CLKSimpleTextProvider(text: "User: ")
modularLargeTemplate.row1Column2TextProvider = CLKSimpleTextProvider(text: "ok")
modularLargeTemplate.row2Column1TextProvider = CLKSimpleTextProvider(text: "Car: ")
modularLargeTemplate.row2Column2TextProvider = CLKSimpleTextProvider(text: "ok")
modularLargeTemplate.row3Column1TextProvider = CLKSimpleTextProvider(text: "Environment: ")
modularLargeTemplate.row3Column2TextProvider = CLKSimpleTextProvider(text: "ok")
template = modularLargeTemplate
case .utilitarianSmall:
template = nil
case .utilitarianLarge:
template = nil
case .circularSmall:
template = nil
default:
template = nil
}
handler(template)
}
如果我在代码中间放置一个断点,调试器会触发它,所以它会执行这段代码。但是没有像我想要的那样显示。
你能找到错误/缺失的东西吗?
答案 0 :(得分:0)
这只是模板,你需要处理os.path.join(root, filename)
,最简单的只是返回与模板相同的条目(见下文)。
正如评论中提到的其他内容一样,您还需要在代码中删除getCurrentTimelineEntry
。
handler(nil)