我正在尝试从WWDC 2014运行“Fit”示例来查看HealthKit。我正在使用iPad air更新到iOS8 beta3。但是,在输入任何信息时,应用程序崩溃并显示错误:
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];
}];
}
答案 0 :(得分:9)
HealthKit不适用于iPad,只有iPhone和iPod - 就像Passbook一样。