問題描述
有誰知道在使用 UIScrollView 時暫時關閉縮放的方法?
Does anyone know a way to temporarily turn off zooming when using a UIScrollView?
我發現您可以使用以下方法禁用滾動:
I see that you can disable scrolling using the following:
self.scrollView.scrollEnabled = false;
但我沒有看到類似的縮放命令.有什么想法嗎?
but I'm not seeing a similar command for zooming. Any thoughts?
推薦答案
如果您想禁用用戶通過手勢縮放的能力,那么在 iOS 5 及更高版本中,您可以禁用捏合手勢.這仍然允許您從代碼中控制滾動視圖...
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;
對于泛...
scrollView.panGestureRecognizer.enabled = NO;
這必須在 - (void)viewDidAppear:(BOOL)animated
或更高版本中調用,否則系統會將其重置為啟用.
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
這篇關于關閉 UIScrollView 中的縮放的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!