Facebook Graph APIを使用して、に表示する200x200
のプロフィール画像の文字列URLを取得しました。私は正常にこれを行うことができますが、画像が画面に表示されるまでに10秒かかることがあります。誰も私にそれを最適化する方法のいくつかのポインタ(意図した馬鹿)を与えることができますか?ローレゾッド画像の読み込みに時間がかかります
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: self.profilePictureUrl)!, completionHandler: { (data, response, error) ->
Void in
self.profilePictureImageView.image = UIImage(data: data!)
self.profilePictureImageView.layer.cornerRadius = self.profilePictureImageView.frame.size.width/2;
self.profilePictureImageView.clipsToBounds = true
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.view.addSubview(self.profilePictureImageView)
})
}).resume()
}
非同期呼び出しの外でサブビューを追加して、サブブロックの画像を補完ブロックに設定してみてください。 – brandonscript