0

I'm building an app display photo as grid with collection view in Swift

I'm using two storyboards, one with collectionview for photo grid. one storyboard for zoom in photo.

And what i want when click on 1 photo to zoom in and can swipe left - right to go to next / previous item.

The question is what is the best way to do ?

  • Add one more collection view on detail storyboard and clone data from photo grid storyboard? use gesture to swipe left - right to select next - prev cell?

  • Or i can reuse collection view from photo grid storyboard on detail storyboard?

or any other way?

I'm new with ios app. Many tks.

Photo grid storyboard

Detail view storyboard

TomSawyer
  • 3,711
  • 6
  • 44
  • 79

1 Answers1

1

In general, you use a transform to "zoom". This will toggle between no zoom and 2x. Try this on your imageView.

if CGAffineTransformEqualToTransform(someView.transform, CGAffineTransformIdentity) {
    someView.transform = CGAffineTransformScale(someView.transform, 2.0, 2.0)
} else {
    someView.transform = CGAffineTransformIdentity
}

ps you can trigger this with a GestureRecognizer.

Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36
  • so, your way is zoom in an cell and use GestureRecognizer? Image in cell is an thumbnail, and i think i will reload it with bigger image. An zoom is really good option in this case? – TomSawyer Aug 31 '14 at 17:50
  • This is a general way to zoom any view. I was guessing that you have a custom cell class with an imageView as a member. I'd try this and eyeball the result to see if it's acceptable to you. If not, then going to the trouble of using 2 images as you say might be better. – Gene De Lisa Aug 31 '14 at 21:16
  • Yeah, im using 2 images. 1 for collection view grid. 1 for detail view. data get from api. all i want it when click to enlarge photo. i still can swipe - left - right with collection view of grid storyboard – TomSawyer Sep 01 '14 at 06:38
  • So my question is can i reuse collection view from grid collection view ? or i have to create a new one on detail photo view and add swipe-left/right gesture on it? – TomSawyer Sep 01 '14 at 16:42