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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -