SwiftUI slider step broken since iOS 15

My sliders worked fine before iOS 15, but now none of them respect the step setting. No one seems to talk about it when I search. Hasn't anyone else noticed this? Is there a fix?

Answered by OOPer in 692271022

Thanks for showing your code. (And sorry for this site malfunctioning again.)

But if you could show enough code (the view type containing the VStack, what settings is, what Setting is...), more readers would be involved to investigate what is happening.


Anyway, I could have confirmed the difference.

This seems to be a bug of Slider in iOS 15. Have you sent a bug report to Apple?

And unfortunately, I cannot find a simple workaround for this issue as for now.

Can you show your code?

My code looks like this:

VStack {
  HStack { Text("Trades per session: \(Int(settings.tradesPerGame))"); Spacer() }
  Slider( value: $settings.tradesPerGame, in: 5 ... 100, step: 5, onEditingChanged: { editing in if !editing { UserDefaults.standard.set( settings.tradesPerGame, forKey: Setting.tradesPerGame.rawValue ) } } ) { EmptyView() }
}

I tried to post it in an answer, but when I submitted it disappeared. This is the code: VStack { HStack { Text("Trades per session: (Int(settings.tradesPerGame))"); Spacer() } Slider( value: $settings.tradesPerGame, in: 5 ... 100, step: 5, onEditingChanged: { editing in if !editing { UserDefaults.standard.set( settings.tradesPerGame, forKey: Setting.tradesPerGame.rawValue ) } } ) { EmptyView() } }

Trying to post the code in an answer again.

VStack {
	HStack { Text("Trades per session: \(Int(settings.tradesPerGame))"); Spacer() }
	Slider( value: $settings.tradesPerGame, in: 5 ... 100, step: 5, onEditingChanged: { editing in if !editing { UserDefaults.standard.set( settings.tradesPerGame, forKey: Setting.tradesPerGame.rawValue ) } } ) { EmptyView() }
}
Accepted Answer

Thanks for showing your code. (And sorry for this site malfunctioning again.)

But if you could show enough code (the view type containing the VStack, what settings is, what Setting is...), more readers would be involved to investigate what is happening.


Anyway, I could have confirmed the difference.

This seems to be a bug of Slider in iOS 15. Have you sent a bug report to Apple?

And unfortunately, I cannot find a simple workaround for this issue as for now.

SwiftUI slider step broken since iOS 15
 
 
Q