我正在尝试为 watchOS2 制造复杂性。我为我的 iOS 应用程序创建了新目标 - 使用 Glances and Complications 我只想拥有一个模块化大型复杂功能。
当我尝试设置并发症时手表冻结(在模拟器和真实手表上)
这是我的复杂代码:
-(void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void (^)(CLKComplicationTimelineEntry * _Nullable))handler {
if (complication.family == CLKComplicationFamilyModularLarge) {
CLKComplicationTemplateModularLargeColumns *template = [[CLKComplicationTemplateModularLargeColumns alloc] init];
NSString *title = NSLocalizedString(@"TODAYINTAKE", nil);
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithText:title];
template.row2Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"kcal"];
template.row3Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"ml"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([self isDateToday:[defaults objectForKey:@"dateSaved"]]) {
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@",[defaults objectForKey:@"energy"]];
template.row3Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@", [defaults objectForKey:@"water"]];
} else {
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
template.row3Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
}
template.row2ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"energy64"]];
template.row3ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"water64"]];
template.row1ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"64"]];
template.row1Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@" "];
CLKComplicationTimelineEntry *entry = [CLKComplicationTimelineEntry entryWithDate:[NSDate new] complicationTemplate:template];
handler(entry);
} else handler(nil);
}
-(void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void (^)(CLKComplicationTemplate * _Nullable))handler {
if (complication.family == CLKComplicationFamilyModularLarge) {
CLKComplicationTemplateModularLargeTable *template = [[CLKComplicationTemplateModularLargeTable alloc] init];
NSString *title = NSLocalizedString(@"TODAYINTAKE", nil);
template.headerTextProvider = [CLKSimpleTextProvider textProviderWithText:title];
template.row1Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"kcal"];
template.row2Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"ml"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([self isDateToday:[defaults objectForKey:@"dateSaved"]]) {
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@",[defaults objectForKey:@"energy"]];
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@", [defaults objectForKey:@"water"]];
} else {
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
}
handler(template);
} else handler(nil);
}
我CLKComplicationTimeTravelDirectionNone
作为支持的时间旅行方向通过
我很无助,因为我在控制台和模拟器中看不到任何错误,或者设备只是冻结了。
从 Carousel 崩溃报告中,我能够阅读以下信息:
*** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“需要应用程序。bundleID:ql.ManaEU.watchkitapp appToReplace:代理:ql.ManaEU.watchkitapp <(null) Not found in database >' 以未捕获的 NSException abort() 类型异常终止,称为 CoreSimulator 191.4 - 设备:Apple Watch - 42mm - 运行时:watchOS 2.0 (13S343) - 设备类型:Apple Watch - 42 毫米