0

作为创建并发症的起点,静态数据可以通过实现如下所示的 Complications 委托示例代码以下列方式呈现:

这种结构意味着我只能为每个并发症系列创建一个并发症。这是真的?我在这里还有其他选择吗?

例如,除了下面的一个不同类型的模块之外,我将如何创建另一个模块化的小并发症,即。CLKComplicationTemplateModularSmallStackImage 以便两者都显示在模块化小区域中?

这可能是可以管理的用户偏好吗?

#pragma mark - Placeholder Templates

- (void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {
// This method will be called once per supported complication, and the results will be cached


if  (complication.family == CLKComplicationFamilyModularSmall){

    CLKComplicationTemplateModularSmallStackText *template = [[CLKComplicationTemplateModularSmallStackText alloc] init];
    //     template.headerTextProvider = [CLKSimpleTextProvider textProviderWithText:@"Title Text"];
    template.line1TextProvider = [CLKSimpleTextProvider textProviderWithText:@"TEXT1"];
    template.line2TextProvider = [CLKSimpleTextProvider textProviderWithText:@"TEXT2"];
    template.tintColor = [UIColor whiteColor];

    handler(template);


} else if (complication.family == CLKComplicationFamilyModularLarge){


    CLKComplicationTemplateModularLargeStandardBody *template = [[CLKComplicationTemplateModularLargeStandardBody alloc] init];
    template.headerTextProvider = [CLKSimpleTextProvider textProviderWithText:@"Text1"];
    template.body1TextProvider = [CLKSimpleTextProvider textProviderWithText:@"Text2"];
    template.body2TextProvider = [CLKSimpleTextProvider textProviderWithText:@"Text3"];


    UIImage *surfMain = [UIImage imageNamed:@"person"];

    template.headerImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:surfMain];



    handler(template);
}

}
4

1 回答 1

4

目前,您无法为特定家庭提供多种选择。您应该在为该家庭提供的模板中选择最佳模板。

对于您的特定示例,有七种不同的模块化小模板。即使您将自己限制为给用户两个选择,如果每个支持复杂功能的应用程序在特定家庭中提供的选择数量增加一倍或三倍,它也不会很好地扩展。

  • 用户体验视角:

    它避免了破坏性的用户体验,从必须在按应用滚动到按应用的多个选择滚动之间进行转换,只是为了让用户跳过您的选择,转到他们想要选择的不同应用的复杂性。

  • 开发者视角:

    如果用户可以选择同时显示您的应用程序的两个或三个不同的模块化小并发症,那么并发症服务器将不得不多次调用您的特定数据源,以使您的每个活动的并发症保持最新。有每日预算要考虑,更不用说我们的扩展变得有点难以阅读和维护,如果我们必须打开家庭,然后通过特定的模板。

Apple 似乎为用户和开发人员选择了一个好的设计,将其限制为每个家庭一个复杂功能。如果您有理由支持多个,您可以向Apple Watch 团队提交功能请求。

于 2016-01-30T18:53:55.537 回答