2

Some similar questions were asked but none with a definitive answer for this issue . While there are few elements in the stack , i want to disable the scroll in scrollView (which is the natural behaviour in android) .

I can prevent scroll with SrcollView{View}.disabled(true)

However, all interactions with subviews are lost : not Tap,no Drag ... Even simple ideas would be welcome .

it75
  • 125
  • 10
  • I must be missing part of the equation here -- if you don't want the user to be able to scroll, why put it in a `ScrollView`? Is it because you want to toggle the scrolling on and off? – jnpdx Apr 09 '21 at 19:58
  • 1
    yes, in a full contentView space when ther are for example 2 elements in the list , i want the user to be able to interact with those elements but not scroll those elements up and down when there are nothing more to show . If list has for example 20 elements , it make sense to scroll . I would decide when to make it scroll or not (basically when more elements than the screen size ) – it75 Apr 09 '21 at 20:05
  • you can code in this way that scrollView would not used in some condition, that would be more doable – ios coder Apr 09 '21 at 20:12
  • 1
    Thank you SwiftPunk, i thought about this at the last solution use dynamically ScrollView only if more than 20 elements for example .Would be doable but not too reactive i guess for dynamic lists. It is just that i m suprised i couldn t find a more elegant solution so far anywhere . Thank you once more – it75 Apr 09 '21 at 20:23
  • Does this answer your question https://stackoverflow.com/a/60910593/12299030? – Asperi Apr 10 '21 at 15:43
  • Hello, thank you for the comment . I had seen it . It disables scrolling but also any interaction with sub elements , hence i can not really use it – it75 Apr 10 '21 at 23:01
  • Did you ever find a solution to this? – pommefrite Dec 16 '21 at 12:45
  • Not really , i just built a new structure where i passed the value isDisabled as a parameter and then SrcollView{View}.disabled(isDisabled) – it75 Dec 17 '21 at 16:36
  • Now SwiftUI gives us way to do this - solution is here https://stackoverflow.com/a/72525824/12299030. – Asperi Jun 07 '22 at 04:17

0 Answers0