久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 UIScrollView Swift 禁用水平滾動(dòng)

Disabling Horizontal Scrolling from UIScrollView Swift(從 UIScrollView Swift 禁用水平滾動(dòng))
本文介紹了從 UIScrollView Swift 禁用水平滾動(dòng)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

滾動(dòng)視圖

我有一個(gè) UIScrollView,帶有約束 left: 0, top: 0, right: 0, bottom: 0

I have a UIScrollView, with constraints left: 0, top: 0, right: 0, bottom: 0

內(nèi)部滾動(dòng)視圖

在這個(gè) UIScrollView 的頂部是一個(gè) UIImageView 約束 left: 0, top: 0, right: 0, height: 200

At the top of this UIScrollView is a UIImageView with constraints left: 0, top: 0, right: 0, height: 200

在下面我有一個(gè) UITextView 約束 left: 0, top: 0, right: 0, bottom: 0

Underneath this I have a UITextView with constraints left: 0, top: 0, right: 0, bottom: 0

這意味著 UITextView 將根據(jù)其內(nèi)容調(diào)整大小,我為 UITextView<將 scrollingEnabled 設(shè)置為 false/代碼>.

This means the UITextView will resize with respect to its content, and I set the scrollingEnabled to false for the UITextView.

所以,當(dāng)我跑步時(shí),它幾乎完美運(yùn)行.

So, when I run, it almost works perfectly.

其中一個(gè)問題是 UIImageView 占用的空間比實(shí)際屏幕寬度多 10%.因此,啟用了水平滾動(dòng).

The one problem is the UIImageView takes up about 10% more than the actual screen width. Hence, horizontal scrolling is enabled.

我已嘗試添加行

imageView.frame = CGRect(0, 0, screenSize.width, 200)
scrlView.contentSize.width = screenSize.width

但這沒有區(qū)別.我仍然可以水平滾動(dòng),并且圖像視圖仍然比實(shí)際屏幕寬度多出 10% 左右.

but this makes no difference. I can still scroll horizontally and the Image View still takes up around 10% more than the actual screen width.

注意,我沒有在情節(jié)提要中設(shè)置 imageView 屏幕寬度,僅以編程方式設(shè)置.

Note, I have not set imageView screen width in storyboard, only programatically.

有什么想法嗎?

推薦答案

這樣,

Swift 4.0

func scrollViewDidScroll(scrollView: UIScrollView) {
    if scrollView.contentOffset.x>0 {
        scrollView.contentOffset.x = 0
    }
}

而且,你可以設(shè)置這個(gè)屬性:

And, you can set this property:

scrollImg.isDirectionalLockEnabled = true

這篇關(guān)于從 UIScrollView Swift 禁用水平滾動(dòng)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設(shè)置滾動(dòng)視圖內(nèi)容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動(dòng)滾動(dòng))
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運(yùn)行時(shí),使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會(huì)導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 亚洲国产精品va在线看黑人 | 日韩欧美在线一区 | 久久国产高清 | 黄色免费在线观看网站 | 国产精品大片在线观看 | 国产精品久久久久久久久久久久久 | 亚洲一区二区网站 | 午夜电影网 | 能看的av网站 | 国内精品久久影院 | 亚洲一卡二卡 | 国产精品免费一区二区三区四区 | 亚洲国产欧美日韩 | 欧美精品一区二区三区在线 | 三级黄色网址 | 日韩蜜桃视频 | 国产中文字幕在线观看 | 久久久久国产 | 在线观看亚洲精品 | 欧美日韩在线视频观看 | 久久国产欧美日韩精品 | 91精品国产综合久久婷婷香蕉 | 国产精品波多野结衣 | 亚洲精品久久久久久久久久吃药 | 久草新在线 | 久久久国产一区 | 亚洲综合在线网 | 狠狠爱视频 | 一级毛片免费看 | 欧美video | 在线播放国产视频 | 在线观看www | 国产免费色| 日韩精品 电影一区 亚洲 | 日韩一区二区在线视频 | 日本久久精品视频 | 成人免费看片 | 粉嫩av在线 | 欧美4p | 九色 在线| 黄色精品 |