Created
October 2, 2017 13:55
-
-
Save GlobakMaxim/52fbaefced0e2d42352895aa8a1ac20d to your computer and use it in GitHub Desktop.
Как написать код чтобы по нажатию на Segmentedcontrols вывести ImageView in cell TableView?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: 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