Ios 定制时,苹果手表会冻结
我正试图为watchOS2制造复杂性。我已经为我的iOS应用程序创建了一个新的目标——略知一二 我只想要一个大的复杂度 当我运行时,试图将手表冻结(在模拟器和真实手表上) 这是我的代码:Ios 定制时,苹果手表会冻结,ios,watchkit,watchos-2,apple-watch-complication,Ios,Watchkit,Watchos 2,Apple Watch Complication,我正试图为watchOS2制造复杂性。我已经为我的iOS应用程序创建了一个新的目标——略知一二 我只想要一个大的复杂度 当我运行时,试图将手表冻结(在模拟器和真实手表上) 这是我的代码: -(void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void (^)(CLKComplicationTimelineEntry * _Nullable))handler { if
-(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
作为支持的时间旅行方向传递
我很无助,因为我看不到控制台中的任何错误,模拟器或设备只是冻结
从转盘碰撞报告中,我可以阅读以下信息:
***由于未捕获的异常“NSInternalInconsistencyException”,正在终止应用程序,原因是:“需要应用程序。”。bundleID:ql.ManaEU.watchkitapp应用程序替换:代理:ql.ManaEU.watchkitapp'
以NSException类型的未捕获异常终止
调用了abort()
CoreSimulator 191.4-设备:Apple Watch-42mm-运行时:watchOS 2.0(13S343)-设备类型:Apple Watch-42mm
仅供参考,我可以使用您提供的扩展代码定制手表表面。没问题 如果您注意到崩溃日志错误中的bundle id,则系统报告watchkit应用程序(包含watchkit扩展)存在问题 由于未捕获的异常“NSInternalInconsistencyException”,正在终止应用程序,原因是:“需要应用程序。”。bundleID:ql.ManaEU.watchkitapp 您需要追踪watchkit捆绑包的问题所在。首先要开始的是Xcode watchkit应用程序构建目标日志。如果没有错误或警告,请查看iPhone和Apple Watch控制台日志 如果这没有指出问题所在,请检查
Info.plist
以确保这些值有效,并且存在所需的键。同时检查watchkit应用程序目标构建设置
您应该能够使用版本编辑器将Xcode项目与其初始提交进行比较,查看是否无意中更改或删除了某些内容。您正在为
clkcomplicationtemplatemodularargetable
的当前时间线条目提供clkcomplicationtemplatemodularargetable
的占位符模板。并发症占位符模板应与当前时间线条目相匹配。是否检查了设备日志中的崩溃报告?如果watchkit扩展挂起,系统将终止它,但该类型的错误不会显示在控制台中。请提供您的GetPlaceholder TemplateforConcurrency
代码,因为这是ClockKit
自定义您的表面复杂性所依赖的。您好,我已经编辑了问题并提供了您想要的信息。