本文介紹了在 UIScrollView 中禁用垂直滾動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
IB 中有一個選項可以取消選中滾動視圖上的垂直滾動,但它似乎不起作用.
There is an option in IB to uncheck vertical scrolling on a scrollview, but it doesnt seem to work.
如何在代碼而不是IB中將scrollview設置為只水平滾動,而不是垂直滾動?
How can the scrollview be set to only scroll horizontally, and not vertically in the code rather than IB?
推薦答案
嘗試將 contentSize 的高度設置為 scrollView 的高度.然后應該禁用垂直滾動,因為沒有任何東西可以垂直滾動.
Try setting the contentSize's height to the scrollView's height. Then the vertical scroll should be disabled because there would be nothing to scroll vertically.
scrollView.contentSize = CGSizeMake(scrollView.contentSize.width,scrollView.frame.size.height);
這篇關于在 UIScrollView 中禁用垂直滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!