enter image description here There is a UIScrollView with horizontal scrolling with loading images from an array (works) - how to scroll only through the frame of images; scrolling now works from any part of the screen


import UIKit import Foundation

class ViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate {

@IBOutlet var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. /************* scroll index ***************/ let korobkaImages = korobka // имя массива let imageWidth:CGFloat = 75 // Ρ€Π°Π·ΠΌΠ΅Ρ€ изобраТСния let imageHeight:CGFloat = 75 let yPosition:CGFloat = 500 // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ ΠΈΠ»ΠΈ позиция ΠΏΠΎ Π£ var xPosition: CGFloat = 20 var scrollViewContentSize:CGFloat=0; for var index=0; index<korobka.count; index++ { let UIEdgeInsetsZero: UIEdgeInsets let korobkaScrollView = scrollView // Π½Π°Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ... let korobkaImage: UIImage = UIImage(named: korobkaImages[index])! let korobkaImageView: UIImageView = UIImageView() korobkaImageView.image = korobkaImage korobkaImageView.contentMode = UIViewContentMode.ScaleAspectFit korobkaImageView.frame.size.width = imageWidth korobkaImageView.frame.size.height = imageHeight korobkaImageView.center = self.view.center korobkaImageView.frame.origin.x = xPosition // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΠΈ korobkaImageView.frame.origin.y = yPosition // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ ΠΈ Π΄Π°Π΅Ρ‚ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π£ korobkaScrollView.addSubview(korobkaImageView) let spacer:CGFloat = 10 xPosition+=imageWidth + spacer // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΠΈ // yPosition+=imageHeight + spacer // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ scrollViewContentSize += imageWidth + spacer // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΠΈ // scrollViewContentSize += imageHeight + spacer // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ korobkaScrollView.contentSize = CGSize(width: scrollViewContentSize, height: imageHeight) // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΠΈ // myScrollView.contentSize = CGSize(width: imageWidth, height: scrollViewContentSize) // для Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° ΠΏΠΎ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ } //скобка закрытия for //var contentInset: UIEdgeInsets // default UIEdgeInsetsZero. add additional scroll area around content 

after launching, scrolling can be done horizontally (by cursor) from any point on the screen β€” you need to by a bar of downloaded images at the bottom of the screen on an image ruler frame ... approximately

  • this was not entirely clear - Max Mikheyenko
  • corrected with the codes ... and how this thing works = it goes through the mail or somehow only through the site @ Max Mikheyenko - user198638
  • What exactly goes through the site // mail? - Max Mikheyenko
  • this thing is @Max Mikheyenko - user198638
  • comments? For example, I have a notification on the phone. What other ways are the notifications sent I don't know - Max Mikheyenko

0