UIScrollView image/photo viewer with paging enabled and zooming

后端 未结 8 861
有刺的猬
有刺的猬 2020-12-07 07:01

OK, I think it\'s time to make an official place on the internet for this problem: How to make a UIScrollView photoviewer with paging and zooming. Welcome my fe

相关标签:
8条回答
  • 2020-12-07 07:53

    I did some playing around with the native Photos app, and I think I can say with confidence they are using a single UIScrollView. The giveaway is this: zoom in on an image, and pull to the left or right. You will see the next or previous photo. If you tug hard enough, it will even page to the next photo at 1.0f zoom. Flip back and the previously zoomed photo will be back to 1.0f zoom as well.

    This is wrong. I'm using nested scrollviews, and getting exactly the same effect. If you're using some memory management scheme (which I had to start using... my page number is fairly high ('bout 50 each in 2 scrollViews)), then you can use a mechanism similar to whatever you have triggering your page loads / unloads to trigger a zoom reset for the pages -1 and +1 from the current page.

    I suspect that apple sets this off as soon as the previous pic has disappeared.

    What I don't understand is how to achieve smooth scrolling between pages - there's always a very short hang at the moment of transition. Do not get it. I've gotten pretty deep into fixing it - NSInvocationOperations were my first stop, then I made a reusable views queue for the page views (which retain their image views)... still this durned hang.

    I only have one NSOperationQueue running, and I've tried fiddling with the max number of concurrent operations. My thought was that the main thread was getting clogged by competing Queues, or maybe even one queue trying to do to much... still, the hang.

    I even tried creating super low-qual versions of my media, in case that was the problem. With each image weighing in at around 10k (these are jpegs, mind you)... you guessed it. The hang's still there.

    I'm pretty much resolved to do what I've done before and use TTPhotoViewController from Three20. I've spent some hours swimming through that code, and it's always a great education. At this point, though, I would really like to know where the heck this hang comes from, if only so I can spend my can't-sleep hours wondering about something less brain boiling.

    0 讨论(0)
  • 2020-12-07 07:55

    i write a code for that , and can be as reference

    1. load current view scrollview and imageview .. and for the screen next to the current view , only imageview

    2. remove all view when current page load to save memory , so good for many photo project

    3. use tag to differentiate different scrollview

    first page_xxxxslidexxxzoom

    the download link click here

    0 讨论(0)
提交回复
热议问题