我在我的awakeWithContext中有一个工作MKMapSnapshotter,我想为我的imageView设置它的图像。
问题是,MKMapSnapshotter会慢下来,图像不会被设置。仅在一两秒钟后,它就会创建快照映像。
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
var finalImage = UIImage()
var snapshotterEnd = MKMapSnapshotter()
snapshotterEnd.startWithCompletionHandler(){snapshot, error in
finalImage = snapshot.image
}
imageView.setImage(finalImage)
}我怎么才能解决这个问题?
发布于 2015-04-10 11:27:07
您需要确保完成处理程序本身将设置图像。
snapshotterEnd.startWithCompletionHandler() { snapshot, error in
imageView.setImage(snapshot.image)
}完成块被记录为在主线程上运行,因此您不需要使用dispatch_async在那里运行它。
https://stackoverflow.com/questions/29559429
复制相似问题