从照片库中选择要使用 xcode 和 swift 显示在 Apple Watch 上的图像视图中的图像



我一直在尝试设置一个UIImageView,允许用户从他们的苹果手表中选择图像,然后将其显示到UIImageView。 但是,我试图解决这个问题并没有成功。 只有有关如何为手机执行此操作的示例。

我已经尝试了解释如何从照片库中获取图像然后将其显示到 UIImageView 的示例,但对于尝试做同样事情但对于苹果手表的手机来说,它不起作用。

这是人们一直在尝试解决此问题的示例,但针对手机而不是苹果手表

class ViewController: UIImagePickerController, UINavigationControllerDelegate, UIImagePickerControllerDelegate  {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
        var imagePickerController = UIImagePickerController()
        imagePickerController.delegate = self
        imagePickerController.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
        imagePickerController.allowsEditing = true
        self.presentViewController(imagePickerController, animated: true, completion: { imageP in
        })
    }

    func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
        let selectedImage : UIImage = image
        println(selectedImage)
    }
}

预期的结果是能够单击链接到UIImageView的按钮,然后弹出照片库,并允许我选择一个图像,然后将其显示在UIImageView上。

Apple Watch 平台没有等效的 UIImagePickerController。您所能做的就是在"反馈助理"中向Apple提交建议,说明此类组件对您有用。对于他们来说,让watchOS图像选择器缩略图既足够可见又可滚动,这将是一个用户体验挑战,但你最好让他们知道,因为他们确实会阅读反馈并做出回应。

最新更新