Setting max-w and max-h in the original code was not actually doing anything.
From the imgix docs: "This parameter will only work if fit=crop is present"
So thumbnails were actually downloaded at 1080w, which in many cases is much larger than necessary, causing unnecessary network and CPU usage.
The call to layoutIfNeeded is required to let Autolayout compute the correct size for the PhotoView first.
Setting max-w and max-h in the original code was not actually doing anything. From the imgix docs: "This parameter will only work if fit=crop is present" So thumbnails were actually downloaded at 1080w, which in many cases is much larger than necessary, causing unnecessary network and CPU usage. The call to layoutIfNeeded is required to let Autolayout compute the correct size for the PhotoView first.