carekit-apple / CareKit

CareKit is an open source software framework for creating apps that help people better understand and manage their health.
https://www.researchandcare.org
Other
2.4k stars 443 forks source link

[Request] iPad Support #24

Closed bishalg closed 8 years ago

bishalg commented 8 years ago

Right now the sample app - OCKSample is iPhone only application. Which can be change to support iPad as well. App looks okay and runs fine, but crashes on "Connect" screen when we try to share via "Send Report" carekit share send report It give following error -

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController:>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'

bishalg commented 8 years ago

We can fix this issue if we add

activityViewController.popoverPresentationController?.sourceView = self.view to the RootViewController.swift

extension RootViewController: OCKConnectViewControllerDelegate {

    /// Called when the user taps a contact in the `OCKConnectViewController`.
    func connectViewController(connectViewController: OCKConnectViewController, didSelectShareButtonForContact contact: OCKContact, presentationSourceView sourceView: UIView) {
        let document = sampleData.generateSampleDocument()
        let activityViewController = UIActivityViewController(activityItems: [document], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = sourceView

        presentViewController(activityViewController, animated: true, completion: nil)
    }
}

Pull Request - #25

umerkhan-apple commented 8 years ago

@bishalg Should we have a separate target for iPad to avoid any issues (such as HealthKit not being available on iPad)?

bishalg commented 8 years ago

Having a separate target for iPad is a overkill for simple app provided. The CareKit framework itself is compatible for both iPhone and iPad. Sample App does not need to use HealthKit features and in fact OCKSample does not use HealthKit feature as of now. Hence I believe the OCKSample should be device independent.

umerkhan-apple commented 8 years ago

@bishalg I agree. Good to go with the #25 then! 👍