UICollectionView and images

安稳与你 提交于 2019-12-08 09:17:51

问题


I have a UICollectionView, and it works great, but I have a doubt. In my view I have a UICollectionViewCell and inside that I have a UIImage. The cell is linked to a blank view controller, and inside that I have a UIScrollView (for managing the zoom) and a UIImage (the full-size image).

I wondered if there was some delegate or something that could handle the image opening process automatically (with zoom, etc.).

Now I'm handling the zoom effect with UIScrollViewDelegate delegate and method viewForZoomingInScrollView:... but the result is very poor, definitely not fluid!


回答1:


There's no built in view for doing what you want, no. You're doing the right thing with a UIImageView inside UIScrollView. If it's not very fluid, then it's likely because your image is huge. The way to get around that is to load different images for different zoom levels. So as you zoom in, listen to the UIScrollViewDelegate method called scrollViewDidZoom: and change the image to better resolution as you zoom in. Or, take a look at CATiledLayer.

Note that this has nothing to do with your UICollectionView.



来源:https://stackoverflow.com/questions/13049056/uicollectionview-and-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!