UISCrollview和Touchesbegan的问题
当用户触摸一个白色Uiviews时,它运行其触摸began:
...
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
delegate.startedTouchingPage(page: self)
...
代表是VC。正如I 认为一样,VC在VC中实施了启动TouchingPage
func startedTouchingPage(page: Page) {
if (page.tool == .PEN || page.tool == .ERASER) {
scrollView.isScrollEnabled = false
scrollView.panGestureRecognizer.isEnabled = false
}
}
这将阻止滚动和平移,并让笔画和平。但是,相反,当我尝试在页面上绘制时,笔有时会正确绘制,有时会滚动页面。
事实证明,页面滚动而不是绘制的时代,touchesbegan没有运行,因此启动touchingpage也没有运行。我不知道为什么...
When a user touches one of the white UIViews, it runs its touchesBegan:
...
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
delegate.startedTouchingPage(page: self)
...
The delegate is the VC. startedTouchingPage is implemented in the VC as
func startedTouchingPage(page: Page) {
if (page.tool == .PEN || page.tool == .ERASER) {
scrollView.isScrollEnabled = false
scrollView.panGestureRecognizer.isEnabled = false
}
}
I thought this would prevent scrolling and panning, and allow the pen to draw in peace. But instead, when I try to draw on the page, the pen sometimes draws properly, and sometimes instead scrolls the page.
It turns out that the times that the page scrolls instead of draws, touchesBegan didn't run, and thus startedTouchingPage didnt run either. I can't figure out why...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论