ios - Disabling Horizontal Scrolling from UIScrollView Swift -
scroll view
i have uiscrollview, constraints left: 0, top: 0, right: 0, bottom: 0
inside scroll view
at top of uiscrollview
uiimageview
constraints left: 0, top: 0, right: 0, height: 200
underneath have uitextview
constraints left: 0, top: 0, right: 0, bottom: 0
this means uitextview
resize respect content, , set scrollingenabled
false
uitextview
.
so, when run, almost works perfectly.
the 1 problem uiimageview
takes 10% more actual screen width. hence, horizontal scrolling enabled.
i have tried adding lines
imageview.frame = cgrect(0, 0, screensize.width, 200) scrlview.contentsize.width = screensize.width
but makes no difference. can still scroll horizontally , image view still takes around 10% more actual screen width.
note, have not set imageview screen width in storyboard, programatically.
any ideas?
like this,
func scrollviewdidscroll(scrollview: uiscrollview) { if scrollview.contentoffset.x>0 { scrollview.contentoffset.x = 0 } }
and, can set property:
scrollimg.directionallockenabled = true
Comments
Post a Comment