Post

Replies

Boosts

Views

Activity

Reply to UI Test on UISegmented Control
Here is some added code to ViewController.swift: // Updates the shoe image's shown func updateShoeImage() { shoeSelection.image = UIImage(named: getShoeParams(type: type, gender: genderLbl.text ?? "", color: color)) } // Sets the value of the text displayed on the UI regarding the parameters func updateOrderResult() { if name == "" || name == "Mr." || name == "Miss" { if gender == "Boy" { name = "Mr." } else if gender == "Girl"{ name = "Miss" } } orderResult.text = """ Hello \(name) I found this pair of \(type.lowercased()) shoes in \(color.lowercased()) size \(sizeLbl.text?.lowercased() ?? "") """ }
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’23
Reply to Display UIStepper's `value` instead of `minimumValue at app's launch
Here is the answer 👇 that I got for the same question on stack overflow, I marked it as "Validated" ✅ : This is an iOS bug. The value property of the stepper set in the storyboard is not honored unless the minimum value is set to 0. For example, if you setup the stepper in the storyboard with a min value of 0, a max value of 100, a value of 50, and a step of 1, then when the view controller loads, the stepper will show a value of 50 as expected. But if you change the min value to 1 and leave everything else the same, then the value will show as 1 instead of 50 when the view controller loads. The simple work around is to set the initial value in code. override func viewDidLoad() { super.viewDidLoad() sizeStepper.value = 40 // work around iOS bug // Sets the first UI's display showSizeValue() } Here is the link 🔗 to the answer: https://stackoverflow.com/a/75738819/16067048
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’23
Reply to Display UIStepper's `value` instead of `minimumValue at app's launch
Here is some additional code from my ViewController.swift file: Declaration of UIStepper and UILabel as IBOutlets lines 21 & 22: @IBOutlet weak var sizeLbl: UILabel! @IBOutlet weak var sizeStepper: UIStepper! Initialization of sizevalue as a String line 35: var size: String = "" Initialization of showSizeValue()function in viewDidLoad() line 46: override func viewDidLoad() { showSizeValue() } showSizeValue() function lines 69-73: func showSizeValue() {     sizeLbl.text = String(Int(sizeStepper.value))     size = sizeLbl.text ?? ""     updateShoeImage() }
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’23