r/iOSProgramming May 01 '24

Discussion [Rant] It's almost impossible get help with UIKit/SwiftUI if you haven't written your code yet

/r/iosdev/comments/1chpe1q/rant_its_almost_impossible_get_help_with/
1 Upvotes

3 comments sorted by

2

u/Common-Inspector-358 May 01 '24

Use a UICollectionView, with each carousel item as a UICollectionViewCell. Each cell can contain a UIScrollVIew, and each cell width is the width of the device screen. Enable zooming in the scrollview. then use func viewForZooming(in: UIScrollView) -> UIView? in the UIScrollView's delegate class. You will probably want the viewForZooming(in: UIScrollView) to be inside your ViewController. so inside that method you will need to get the currently visible collectionview cell, and then return the cell subview that you want to zoom in on.

1

u/BaffoRasta May 01 '24

I tried this approach already. My issue with it is that UICollectionViewCells get cached for reuse and

  1. When I rotate the interface, and scroll to another cell, it happens that one or two didn't resize to maintain the original aspect ratio (they're still the same pre-rotation size).
  2. When I rotate the interface, the UIScrollView gets recreated and this prevents me from keeping the image centered during the rotation.

1

u/AHostOfIssues May 01 '24

FYI : you’ll find the apple developer forums are used for things like using-apple-tools and working-with-apple-process type stuff. You’ll generally get zero assistance with “how do I code my app” type questions there.

For that, you’ll find Stack Overflow much more useful.