-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([HKHealthStore isHealthDataAvailable]){
NSSet *writeDataTypes = [self dataTypesToWrite];
NSSet *readDataTypes = [self dataTypesToRead];
[self.healthStore requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) {
NSLog(@"%s",__func__);
if (!success) {
NSLog(@"You didn't allow HealthKit to access these read/write data types. In your app, try to handle this error gracefully when a user decides not to provide access. The error was: %@. If you're using a simulator, try it on a device.", error);
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
// Update the user interface based on the current user's health information.
NSLog(@"=========================== %s",__func__);
});
}];
}
}
requestAuthorizationToShareTypes不調用回完成方法。requestAuthorizationToShareTypes方法在iOS 8中不顯示權限提示Xcode 6
如果紙張永遠不會出現,並且永遠不會調用完成後,那麼這聽起來像一個你應該提交的bug(bugreporter.apple.com)。你有沒有試過從設備看控制檯輸出,看看是否有任何記錄錯誤? – Allan 2014-09-25 04:28:37
是的,我在控制檯上什麼也沒做。 – 2014-09-25 08:43:02
我有同樣的問題,所以我崩潰:HTTPS://devforums.apple.com/thread/248835 TSTART = 0 – marciokoko 2014-10-02 17:50:46