gpt4 book ai didi

objective-c - 自定义表盘时,watchOS 复杂功能未显示为选项

转载 作者:行者123 更新时间:2023-12-02 20:49:17 31 4
gpt4 key购买 nike

这是我尝试添加的第一个复杂功能。我正在将其添加到当前项目中。我已经设法让它显示在模拟器中,但没有显示在我的实际 watch 上。这只是 SimpleImage 的一个并发症,所以我有点不知所措,而且我在网上没有找到太多关于这个问题的信息。

它显示在复杂功能下,但在自定义表盘时不作为选项。

下面是我的代码:

- (void)getSupportedTimeTravelDirectionsForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimeTravelDirections directions))handler {
//handler(nil);
handler(CLKComplicationTimeTravelDirectionForward|CLKComplicationTimeTravelDirectionBackward);
}

- (void)getTimelineStartDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
handler(nil);
}

- (void)getTimelineEndDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
handler(nil);
}

- (void)getPrivacyBehaviorForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationPrivacyBehavior privacyBehavior))handler {
handler(CLKComplicationPrivacyBehaviorShowOnLockScreen);
}

#pragma mark - Timeline Population

- (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler {
// Call the handler with the current timeline entry
handler(nil);
}

- (void)getTimelineEntriesForComplication:(CLKComplication *)complication beforeDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
// Call the handler with the timeline entries prior to the given date
handler(nil);
}

- (void)getTimelineEntriesForComplication:(CLKComplication *)complication afterDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
// Call the handler with the timeline entries after to the given date
handler(nil);
}

#pragma mark - Placeholder Templates

- (void)getLocalizableSampleTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {
handler(nil);
}

- (void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {

if (complication.family == CLKComplicationFamilyCircularSmall){

CLKComplicationTemplateCircularSmallSimpleImage *template = [[CLKComplicationTemplateCircularSmallSimpleImage alloc] init];

UIImage *img = [UIImage imageNamed:@"Circular"];

template.imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:img];

handler(template);

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

CLKComplicationTemplateModularSmallSimpleImage *template = [[CLKComplicationTemplateModularSmallSimpleImage alloc] init];

UIImage *img = [UIImage imageNamed:@"Modular"];

template.imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:img];

handler(template);

}

}

最佳答案

可以通过两种方式将复杂功能添加到表盘:

  1. 通过强制触摸在 watch 本身上
  2. 在 iPhone 上通过 Face Gallery 部分的 Watch 应用程序

对于这两种工作方式,您应该实现get​Localized​Sample​Template(for:​with​Handler:​) method当用户从列表中选择复杂性时,将调用一次以填充占位符类型。

为了使 Watch.app 中显示复杂功能,您还应该在项目中添加特殊的“complication bundle ”。该 bundle 将存储在 iOS 应用程序中,并且 Watch.app 在需要填充其 Face Gallery 时会找到它。

关于objective-c - 自定义表盘时,watchOS 复杂功能未显示为选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42869884/

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