2017-07-27 71 views
0


我用複雜功能製作了Apple Watch應用程序,並激活了模塊化小型應用程序。我將以下代碼添加到ComplicationController.swift中,但我只能看到一個方形圖標。試圖把文字或圖像放在裏面什麼都不做。
預先感謝您的幫助!
Apple Watch Complication圖標或文字

func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) { 
    var template: CLKComplicationTemplate? 

    switch complication.family { 
    case .modularSmall: 
     template = CLKComplicationTemplateModularSmallSimpleText() 
     (template as! CLKComplicationTemplateModularSmallSimpleText).textProvider = CLKSimpleTextProvider(text: "R") 
    default: 
     template = nil 
    } 
    handler(template) 
} 

回答

0

當你只有把模板中只會顯示在當你想改變的併發症出現的模板列表中getPaceholderTemplete()方法。

選擇併發症後,它會調用getCurrentTimelineEntry()。這是您需要插入您想要顯示的模板的位置,一旦複雜化被激活。你的代碼看起來很好,所以如果你只是複製並粘貼你的switch語句到get​​CurrentTimelineEntry()它應該工作。