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

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

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

問(wèn)題描述

滾動(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è)問(wèn)題是 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

但這沒(méi)有區(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.

注意,我沒(méi)有在情節(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)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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 可縮放?)
主站蜘蛛池模板: 国产高清视频一区 | 国产欧美一区二区三区久久手机版 | 一本久久a久久精品亚洲 | 中文字幕国产精品 | 亚洲一区二区av | 99精品久久久 | 人人看人人爽 | 精品国产免费一区二区三区演员表 | 波多野结衣一区二区 | 国产精品久久777777 | 一a一片一级一片啪啪 | 国产一级片免费视频 | 精品视频成人 | 欧美一级做性受免费大片免费 | 精品久草 | 亚洲激情视频在线 | 91电影| 久操亚洲 | 久久88| 青青草视频网 | 中文字幕观看 | 91久久精品一区二区二区 | 懂色tv| www.色综合 | 91 在线| 成人精品视频在线观看 | 天天影视亚洲综合网 | 成人免费共享视频 | 色综合一区二区三区 | 91视频在线观看免费 | 国产在线一区二区三区 | 91av视频在线免费观看 | 二区中文| 国产高清免费视频 | 精品国产欧美一区二区三区成人 | 欧美嘿咻 | 欧美 日本 国产 | 国产精品高清一区二区 | 国产成人在线一区二区 | 中文字幕国产精品 | 亚洲精品一区二区三区在线 |