2016-11-22 11 views

답변

0

그 어떤 framwork는하지만이 확장을 작성했습니다 :

extension WKInterfaceImage { 
    public func imageFromUrl(_ urlString: String) { 

     if let url = NSURL(string: urlString) { 

      let request = NSURLRequest(url: url as URL) 
      let config = URLSessionConfiguration.default 
      let session = URLSession(configuration: config) 

      let task = session.dataTask(with: request as URLRequest, completionHandler: {(data, response, error) in 
       if let imageData = data as Data? { 
        DispatchQueue.main.async { 
         self.setImageData(imageData) 
        } 
       } 
      }); 

      task.resume() 
     } 
    } 
} 

그냥 당신의 watchOS 스토리 보드에 WKInterfaceImage을 추가 첨부하고 imageView.imageFromUrl("https://something")

날 작동하는지 알려 불러!