2

我正在尝试运行 WWDC 2014 中的“Fit”示例来查看 HealthKit。我正在使用更新到 iOS8 beta3 的 iPad air。但是,当输入任何信息时,应用程序会因错误而崩溃:

Error Domain=com.apple.healthkit Code=1 "Health data is unavailable on this device"

这是产生错误的方法的示例

    - (void)saveHeightIntoHealthStore:(double)height {
        // Save the user's height into HealthKit.
        HKUnit *inchUnit = [HKUnit inchUnit];
        HKQuantity *heightQuantity = [HKQuantity quantityWithUnit:inchUnit doubleValue:height];

        HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
        NSDate *now = [NSDate date];

        HKQuantitySample *heightSample = [HKQuantitySample quantitySampleWithType:heightType quantity:heightQuantity startDate:now endDate:now];

        [self.healthStore saveObject:heightSample withCompletion:^(BOOL success, NSError *error) {
            if (!success) {

//Error reported here

                NSLog(@"An error occured saving the height sample %@. In your app, try to handle this gracefully. The error was: %@.", heightSample, error);
                abort();
            }
            [self updateUsersHeight];
        }];
    }
4

1 回答 1

10

HealthKit 在 iPad 上不可用,仅在 iPhone 和 iPod 上可用 - 就像 Passbook。

于 2014-07-17T18:49:52.040 回答