11

我正在尝试为 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 毫米

4

2 回答 2

0

您正在为 的当前时间线条目提供占位符模板。并发症占位符模板应与当前时间线条目匹配。CLKComplicationTemplateModularLargeTableCLKComplicationTemplateModularLargeColumns

于 2016-02-29T19:25:37.303 回答
0

仅供参考,我可以使用您提供的扩展代码自定义表盘。那里没问题。

如果您在崩溃日志错误中注意到 bundle id,则系统报告 watchkit 应用程序(其中包含 watchkit 扩展)存在问题。

由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“需要应用程序。bundleID: ql.ManaEU.watchkitapp ...

您需要找出 watchkit 捆绑包出了什么问题。首先要从 Xcode watchkit 应用程序构建目标日志开始。如果那里没有错误或警告,请检查 iPhone 和 Apple Watch 控制台日志。

如果这没有指出问题所在,请检查Info.plist以确保这些值有效,并且存在所需的键。还要检查 watchkit 应用程序目标构建设置。

您应该能够使用版本编辑器将 Xcode 项目与其初始提交进行比较,以查看是否有某些内容被无意更改或删除。

于 2015-12-14T16:27:04.440 回答