Skip to content

Instantly share code, notes, and snippets.

@GlobakMaxim
Created October 2, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GlobakMaxim/52fbaefced0e2d42352895aa8a1ac20d to your computer and use it in GitHub Desktop.
Save GlobakMaxim/52fbaefced0e2d42352895aa8a1ac20d to your computer and use it in GitHub Desktop.
Как написать код чтобы по нажатию на Segmentedcontrols вывести ImageView in cell TableView?
//: Playground - noun: a place where people can play
import UIKit
enum Result: String {
case mineral
case notMineral
}
enum ProductType {
case newFilter
case setCartridge
}
enum ProductLevel {
case classicUTs
case easyFitUTS
case jug
}
let imageResultNameDictionary = [
"0_0_0" : "image1",
"0_0_1" : "image2",
"0_0_2" : "image3",
"0_1_0" : "image4",
"0_1_1" : "image5",
"0_1_2" : "image6",
"1_0_0" : "image7",
"1_0_1" : "image8",
"1_0_2" : "image9",
]
private func updateImage() {
let result: Result = .mineral // Info from TextField
let productType: ProductType = .newFilter // Info from segmentedControl
let productLevel: ProductLevel = .jug // Info from segmentedControl
let imageHashName = "\(result.hashValue)_\(productType.hashValue)_\(productLevel.hashValue)"
let imageName = imageResultNameDictionary[imageHashName] ?? "defaultImage"
imageView.image = UIImage(named: imageName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment