問(wèn)題描述
有誰(shuí)知道在使用 UIScrollView 時(shí)暫時(shí)關(guān)閉縮放的方法?
Does anyone know a way to temporarily turn off zooming when using a UIScrollView?
我發(fā)現(xiàn)您可以使用以下方法禁用滾動(dòng):
I see that you can disable scrolling using the following:
self.scrollView.scrollEnabled = false;
但我沒(méi)有看到類似的縮放命令.有什么想法嗎?
but I'm not seeing a similar command for zooming. Any thoughts?
推薦答案
如果您想禁用用戶通過(guò)手勢(shì)縮放的能力,那么在 iOS 5 及更高版本中,您可以禁用捏合手勢(shì).這仍然允許您從代碼中控制滾動(dòng)視圖...
If you want to disable the user's ability to zoom through gestures then in iOS 5 and above you can disable the pinch gesture. This still allows you to control the scroll view from code...
scrollView.pinchGestureRecognizer.enabled = NO;
對(duì)于泛...
scrollView.panGestureRecognizer.enabled = NO;
這必須在 - (void)viewDidAppear:(BOOL)animated
或更高版本中調(diào)用,否則系統(tǒng)會(huì)將其重置為啟用.
This must be called in - (void)viewDidAppear:(BOOL)animated
or later as otherwise the system resets it to enabled.
Swift 4.x 及更高版本:
imageZoomView.pinchGestureRecognizer?.isEnabled
= false/true
這篇關(guān)于關(guān)閉 UIScrollView 中的縮放的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!