[英]iOS temporarily disable Page View Controller swiping
I have a setup where I have a Page View Controller
set up to navigate between different views
. 我有一个设置,其中有一个
Page View Controller
,可以在不同的views
之间导航。
In some of these views I will have a custom drawing view
where the user can draw with their finger to create a picture. 在这些视图中的某些视图中,我将具有一个
custom drawing view
,用户可以在其中用手指绘图以创建图片。
The problem with this, the user is not able to make a drawing gesture left/right
because the page view controller
will take over and navigate to a different view. 与此相关的问题是,由于
page view controller
将接管并导航到其他视图,因此用户无法left/right
做出绘画手势。
I was wondering what a good approach would be to temporarily disable the swiping
for the page view controller
to allow the user to draw
. 我想知道暂时禁用
page view controller
的swiping
以允许用户draw
的好方法是什么。
I was thinking when the user first interacts with the drawing view
it would disable the page swiping
and create a finished drawing button
. 我在想,当用户第一次与工程
drawing view
交互时,它将禁用page swiping
并创建finished drawing button
。 When this button is clicked it would reenable the page swiping
. 单击此按钮后,将重新启用
page swiping
。 Does this seem reasonable, or does anybody know of any better approaches? 这看起来合理吗,还是有人知道更好的方法吗?
Using this you can stop Scrolling 使用这个可以停止滚动
for (UIScrollView *view in self.pageViewController.view.subviews) {
if ([view isKindOfClass:[UIScrollView class]]) {
view.scrollEnabled = NO;
}
}
I'd look into this UIGestureRecognizerDelegate
method: 我将研究以下
UIGestureRecognizerDelegate
方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
Here you can "kill" the page view controller's gesture recognizer by disabling and re-enabling it: 在这里,您可以通过禁用并重新启用它来“杀死”页面视图控制器的手势识别器:
if (/* otherGestureRecognizer is page view controller's */) {
otherGestureRecognizer.enabled = NO;
otherGestureRecognizer.enabled = YES;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.