downinja
downinja

Reputation: 3

Creating a Slider that changes maximum value if released at maximum

Probably a fairly basic error as I am fairly new to swift. I have an app that creates a slider with min and max values. These minimum and maximum values will only be a start point, so if someone sets the maximum value I would like to reset the maximum value to something greater.

In xcode I have linked the action to touch up inside.

@IBAction func increaseslider(Sender: AnyObject){
if slider.value = slider.maximumvalue{

I get errors at this point? Is there a simpler way to do this? Or I barking up the wrong tree?

Upvotes: 0

Views: 1255

Answers (1)

trevorj
trevorj

Reputation: 2039

One problem with your code that may be giving you errors:

@IBAction func increaseslider(Sender: AnyObject){
if slider.value = slider.maximumvalue{

You need to use a double equals sign in the if clause:

if slider.value == slider.maximumValue

Upvotes: 1

Related Questions