DEV Community

Logan
Logan

Posted on

1

100 Days of Code: Day 4

This is one of those times when I thought I was going to learn one thing, but ended up with a completely different lesson. I didn't post last night because I fought with it, said screw it, went to bed and played there for two hours thinking about it. I just couldn't let go of it.

I started off by building a simple app called StinkLock. 4 labels, 3 sliders and a button. The idea was once the sum of the sliders equaled something or some sequence of values, the button would become active to tap and show a modal screen. Related aside, practically every little thing I do to reinforce an idea always becomes some way of telling my kid they stink.

I put everything in the main.storyboard. I put the UILabels that showed the value rounded to whole numbers above the UISlider. I put the UILabels and UISliders in their own StackView. I put those three in a stack together, constrained to center horizontal and vertical. I added my @IBActions and @IBOutlets. All I really needed to do was decide on the functions to change the button state from disabled to active, add the segue and call it done.

I ran my app in the simulator. Slider buttons didn't move. Ran it on my phone. Same thing. I added the slider.minumumValue and slider.maximumValue properties in the viewDidLoad(). Didn't budge. I tinkered with the content mode properties. Nothing. That's when I went to bed to brood over it. 3 hours of sleep.

After a bit of hard googling and slamming back an energy drink, I found it. Every time I embedded the elements into the StackView, my leading and trailing were clipped, by the time I had it three stacks deep, the slider had no room to wiggle. I removed all of my constraints, rebuilt the layout. It works fine. Exactly what I wanted it to do. I'm sure I muttered some vulgarities to myself.

I did watch a tutorial on optionals, read a few articles on them. But nothing is going to stick with me like the sleep depriving struggle I had with a simple UISlider.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️